Skip to main content

Clear client side people picker control

 Use below function to clear the people picker control values from page on client side.


Code:



Function clearPeoplePicker(pickerId) {
    var toSpanKey = pickerId+"_TopSpan";
    var peoplePicker = null;

    // Get the people picker object from the page.
    var ClientPickerDict = this.SPClientPeoplePicker.SPClientPeoplePickerDict;
    // Get the people picker object from the page.
    for (var propertyName in ClientPickerDict) {
        if (propertyName == toSpanKey) {
            peoplePicker = ClientPickerDict[propertyName];
            break;
        }
    }

    if (peoplePicker) {
        var ResolvedUsersList = $(document.getElementById(peoplePicker.ResolvedListElementId)).find("span[class='sp-peoplepicker-userSpan']");
        $(ResolvedUsersList).each(function (index) {
            peoplePicker.DeleteProcessedUser(this);
        });
    }
}

Comments

Post a Comment

Popular posts from this blog

Query SharePoint List - SPQuery vs SPSiteDataQuery vs CrossListQueryInfo

There are three different classes you can use to query SharePoint list:-
1.SPQuery
Used for query a data from a specific list and also used for join two lists.
Use full Links:-
·http://sharepointfordeveloper.blogspot.in/2011/10/step-by-step-spquery-list-joins.html#!/2011/10/step-by-step-spquery-list-joins.html
·http://mysharepointwork.blogspot.in/2010/04/spquery-examples.html

2.SPSiteDataQuery