0

I recently watched a video which popped-up a SharePoint Dialog box (Webpage Dialog) to browse site content, and then return the selection value to a text box. Is it possible to invoke this dialog box through code to Browse Site Content and return the selected value to a variable/Control ? Or do we have to implement this from scratch ?

enter image description here

1 Answer 1

0

The following JavaScript function when called will pop up the browse dialog in a modal window and if the user makes a selection will return an array of four elements:

  • element 0: guids of list, web
  • element 1: base URL (e.g./sites/sitecollection2)
  • element 2: library display name (e.g. Documents)
  • element 3: library URL (e.g. /sites/sitecollection2/Shared Documents)

You can examine the querystring on the PickerTreeView page to see what the parameters are and how they are used.

function showBrowseDialog() {
    var qs = 'title=RouterPickerSelectListTitle&text=RouterPickerSelectListText&filter=websListsFolders&root=&selection=&featureId=&errorString=&iconUrl=/_layouts/15/images/smt_icon.gif?rev=39&scopeToWeb=true&requireCT=&sourceId=';
    var url = SP.ClientContext.get_current().get_url() + '/_layouts/15/PickerTreeView.aspx?' + qs;

    var result = window.showModalDialog(url, null, "dialogHeight: 700px; dialogWidth: 525px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; resizable: No; status: Yes;");
    if(result)
        alert('You selected ' + result[3]);
    else
        alert('You hit cancel');
}
1
  • Note this will not work in chrome and possibly firefox due to the lack of support for showModalDialog. For those browsers you need to just use a standard window. Commented May 22, 2015 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.