I am trying to make people picker column in my list edit form "Read-only". I found many solutions that worked on SharePoint 2010 but couldn't find a reliable solution for SharePoint 2013/Office 365.
It would be great if someone can point me to a good solution.
To make People picker readonly, you can use the below JQuery code:
$(".sp-peoplepicker-delImage").css({ 'display' : 'none'});
$(".sp-peoplepicker-editorInput").css({ 'display' : 'none'});
You can also apply them with the help of css:
<style>
.sp-peoplepicker-delImage{
display:none;
}
.sp-peoplepicker-editorInput{
display:none;
}
</style>
This is the easiest and fastest way to make people picker fields read only in SharePoint
2013/online, but it will make every people picker field on the form read only. So please let
me know if you want for a specific column.
Since in SharePoint 2013 for rendering List Forms was introduced a new client side rendering engine (called CSR) that is based on JavaScript/HTML i would recommend the following approach. To customize edit form in order to render People Picker in edit form using display mode as explained below.
Steps
1) Create a JavaScript template for rendering People Picker in display mode:
SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
Templates: {
Fields: {
"AssignedTo": {
EditForm: renderAssignedTo
}
}
}
});
});
function renderAssignedTo(ctx) {
var item = ctx['CurrentItem'];
var userField = item[ctx.CurrentFieldSchema.Name];
var fieldValue = "";
for (var i = 0; i < userField.length; i++) {
fieldValue += userField[i].EntityData.SPUserID + SPClientTemplates.Utility.UserLookupDelimitString + userField[i].DisplayText;
if ((i + 1) != userField.length) {
fieldValue += SPClientTemplates.Utility.UserLookupDelimitString
}
}
ctx["CurrentFieldValue"] = fieldValue;
return SPFieldUserMulti_Display(ctx);
}
2)Open Edit Form page in edit mode
3)Place Script Editor web part on the page and insert the specified template by enclosing it using script tag
That's it.
Result
¨
Related
How to fix the problem of having the navbar as position: fixed in Sitecore 9.3. I saw some solutions on the blogs, but it only fixes the issue on the Sitecore 8 versions.
Basically when I open the partial design in Sitecore Experience Editor, I have set my navbar as position fixed in theme css file, and it shows the navbar below the scWebEditRibbon. I also saw that scWebEditRibbon is now position fixed, still it does not fix my issue since I also have position fixed on my element.
I fixed the issue by using the script provided Richard Szalay, I just changed the variable as you can see here:
Here is the script:
// Repositions a position-fixed header so that it always appears under the SC experience editor ribbon
define(["sitecore"], function (Sitecore) {
return {
priority: 50,
execute: function (context) {
// TODO: Change this CSS selector to suit your application
var FIXED_NAV_SELECTOR = '#navbar';
// the 'cross piece' is a blank div that is sized to match the iframe content (where the actual ribbon is)
var scWebEditRibbon = window.parent.document.getElementById('scWebEditRibbon');
var nav = window.parent.document.querySelector(FIXED_NAV_SELECTOR);
if (scWebEditRibbon && 'MutationObserver' in window) {
var observer = new MutationObserver(function (mutations) {
nav.style.top = scWebEditRibbon.style.height;
});
observer.observe(scWebEditRibbon, { attributes: true, attributeFilter: ['style'] });
}
}
};
});
I am a new user of kendo and I have a problem with a gantt!
I have a page with a Gantt kendo. For each activity I have a button edit. When my popup edit is open I have lot of fields and a multiselect. This multiselect should be specific for each activity.
I have put the code below in my function edit Gantt :
$.get('/Activity/ReadMultiSelectActivities?initiativeId=' + #Model.ID + '&excludeSectorId=' + $('#SectorID').val() + "&activityID=" + e.task.id, function (data, status) {
allActivitiesDataSource = new kendo.data.DataSource({
data: data.Data,
group: { field: "SectorName" },
sort: { field: "ActivityNumberString", dir: "asc" }
});
});
var msLinkedActivities = $('#linkedActivities').data('kendoMultiSelect');
msLinkedActivities.setDataSource(allActivitiesDataSource);
My problem is that I get the impression that my code is read into account with a delay time. That is, if I click on edit activity 1 the first time the list is empty, I close the edit and then return to edit activity 1 the list is filled. If then I go on edit activity 2 it will be the list of activity 1 ...
I tried many things that I view on tuto, demo and forum telerik but nothings function!
Have you an Idea for fix this problem please?
For information I have resolve my probelm. This is because the data are long to retrieve and so it made the setDataSource before loading the data!
I am using an Infragistics NetAdvantage WebDataGrid with filtering set.
On page load, I would like to open the first filter’s textbox, and set the focus there, so that it is ready for the user to start typing the text with which to filter.
I have seen an example online of how to do this for the jQuery grid, but not for the WebDataGrid
I want something along the lines of:
myWebDataGrid.Behaviors.Filtering.ColumnFilters[2].RuleTextNode.focus;
I am using Infragistics35.Web.v11.2, Version=11.2.20112.2025
To do this you can call enterEditMode on the filter row when your page loads, passing in the specific cell you want edit:
function enterEditFilter() {
var grid = $find('<%= grid.ClientID %>');
var filtering = grid.get_behaviors().get_filtering();
var filterRow = filtering._row;
var cell = filterRow.get_cellByColumnKey('Text');
filtering.enterEditMode(cell);
}
Please note that to do this you have to be able to get access to the filter row. It doesn't appear that there is a way to access this through the public API so I use the private variable _row. This is not a recommended approach as that variable may change, so I suggest that you submit a new product idea to have the filter row added to the public API. You can do this on the following page:
http://ideas.infragistics.com/
Another thing to note is that the default filter type is "All" so you'll also want to change this. You can do this by handling the client side filtering event and setting the rule there:
function grid_filtering(sender, eventArgs) {
var filters = eventArgs.get_columnFilters();
for (var i = 0; i < filters.length; i++) {
var condition = filters[i].get_condition();
if (condition.get_rule() === 0) {
var columnType = filters[i].get_columnType();
if (columnType == 'string') {
condition.set_rule($IG.TextFilterRules.Equals);
}
else if (columnType == 'number') {
condition.set_rule($IG.NumericFilterRules.Equals);
}
}
}
}
I am creating a custom item editor, and am using the following blog post as a reference for responding to the "save" event in the Content Editor, so that I do not need to create a second, confusing Save button for my users.
http://www.markvanaalst.com/sitecore/creating-a-item-editor/
I am able to save my values to the item, but the values in the normal Content tab are also being saved, overriding my values. I have confirmed this via Firebug. Is there a way to prevent this, or to ensure my save is always after the default save?
I have this in as a support ticket and on SDN as well, but wondering what the SO community can come up with.
Thanks!
Took a shot at an iframe-based solution, which uses an IFrame field to read and save the values being entered in my item editor. It needs to be cleaned up a bit, and feels like an interface hack, but it seems to be working at the moment.
In my item editor:
jQuery(function () {
var parentScForm = window.parent.scForm;
parentScForm.myItemEditor = window;
});
function myGetValue(field) {
var values = [];
jQuery('#myForm input[#name="' + field + '"]:checked').each(function () {
values.push(jQuery(this).val());
});
var value = values.join('|');
return value;
}
In my Iframe field:
function scGetFrameValue() {
var parentScForm = window.parent.scForm;
if (typeof (parentScForm.myItemEditor) != "undefined") {
if (typeof (parentScForm.myItemEditor.myGetValue) != "undefined") {
return parentScForm.myItemEditor.myGetValue("myLists");
}
}
return null;
}
In theory, I could have multiple fields on the item which are "delegated" to the item editor in this way -- working with the content editor save rather than trying to fight against it. I'm a little uneasy about "hitchhiking" onto the scForm to communicate between my pages -- might consult with our resident Javascript hacker on a better method.
Any comments on the solution?
EDIT: Blogged more about this solution
When you insert a flash object into the CKeditor the editor window will show this symbol:
I was wondering. Is it possible to do something similar when users inserts this tag into the editor (using regex {formbuilder=(\d+)}/ ):
{formbuilder=2}
If so, could someone please explain how to? :)
UPDATE:
I've been looking at the PageBreak plugin to try and understand what the hell is going on. The big difference between this plugin and mine is the way the HTML is inserted into the editor.
CKEDITOR.plugins.add('formbuilder',
{
init: function(editor)
{
var pluginName = 'formbuilder';
var windowObjectReference = null;
editor.ui.addButton('Formbuilder',
{
label : editor.lang.common.form,
command: pluginName,
icon: 'http://' + top.location.host + '/publish/ckeditor/images/formbuilder.png',
click: function (editor)
{
if (windowObjectReference == null || windowObjectReference.closed){
var siteid = $('#siteid').val();
windowObjectReference = window.open('/publish/formbuilder/index.php?siteid='+siteid,'Formbuilder','scrollbars=0,width=974,height=650');
} else {
windowObjectReference.focus();
}
}
});
}
});
As you can see, my plugin opens a new window and the tag is inserted with:
function InsertForm(form_id)
{
// Get the editor instance that we want to interact with.
var oEditor = CKEDITOR.instances.page_content;
// Check the active editing mode.
if ( oEditor.mode == 'wysiwyg' )
{
// Insert the desired HTML.
oEditor.insertHtml( '{formbuilder='+form_id+'}' );
}
else
alert( 'You must be on WYSIWYG mode!' );
}
The PageBreak plugin does everything when you click on the toolbar icon. This makes it possible to make the fakeImage inside the plugin file. For me on ther other hand, I don't see how this is possible :\
I'm looking to solve a similar issue, except that all my stuff looks like XML. So like, <cms:include page="whatever" />. In your case, you would be able to copy the placeholder plugin and change the placeholder regex to match your tags. In my case, looks like I'll be modifying the iframe plugin or something, and hopefully figuring out how to add each of my tags as self-closing...