I found some difficulties in hiding SharePoint People Picker control indexed wise.
Suppose I want to hide only 2nd and 3rd people picker control from SharePoint New and Edit List Form.
here is the solution.
$(document).ready(function() {
var Attendees = GetIDOfPeoplePicker(2);
var Attendee = GetIDOfPeoplePicker(3);
$("#"+Attendees+"").closest('Div').closest('span').closest('td').closest('tr').hide();
$("#"+Attendee+"").closest('Div').closest('span').closest('td').closest('tr').hide();
});
function GetIDOfPeoplePicker(iIndex)
{
var sID = "";
var iFound = 0;
var docTags = document.getElementsByTagName("textarea");
for (var i=0; i < docTags.length; i++)
{
if (docTags[i].title == "People Picker")
{
iFound ++;
if (iFound == iIndex)
{
sID = docTags[i].previousSibling.id;
break;
}
}
}
return sID;
}
Update for SharePoint 2013 Client Picker Control:
To disable the input Filed of Client Picker
$("input.sp-peoplepicker-editorInput[id*='<ID part of ClientPicker Contrl>']").prop('disabled', true);
To hide the input Filed of Client Picker
$("a[id*='<ID part of ClientPicker Contrl>']").hide();
thank you so much!
ReplyDeleteGreat Article !! Really helpFul
ReplyDelete