Understanding the List Dialogs setting in SharePoint 2010

Overview

With the introduction of SharePoint 2010 two modes became available  when working with Libraries/List forms   from user experience perspective. Dialogs option in List Settings indicates whether to navigate the full page (Yes) or that the list form page is launched in a modal dialog (No)

XLV_DialogsOption

Figure 1. List settings 

Pay attention to the last part of the description that says:

Note: Dialogs may not be available on all forms.

Interesting, isn’t it, but what exactly does it mean? In order to find out we need to investigate how List Dialogs settings is handled in SharePoint 2010.  So, Let’s get started.

How it works

Depending on which option is selected link events for List/Library forms (New|Edit|View) are handled differently. When the “Launch forms in a dialog” is selected form pages are opened in modal dialog boxes.

How it is implemented

Through SharePoint Object Model the specified List settings for enabling/disabling modal dialog boxes is accessible via  SPList.NavigateForFormsPages property.   As it turns out, the value of  this property is passed to the XSL transform via  XsltListViewWebPart.ModifyXsltArgumentList method:

/// <summary>
/// Partial implementation of XsltListViewWebPart.ModifyXsltArgumentList method
/// The remaining code is omitted for clarity here
/// </summary>
protected override void ModifyXsltArgumentList(ArgumentClassWrapper argList)
{
argList.AddParameter("NavigateForFormsPages", string.Empty, this.SPList.NavigateForFormsPages ? (object) BaseXsltListWebPart.XslOneString : (object) BaseXsltListWebPart.XslZeroString);
}

The XSLT global parameter NavigateForFormsPages  declared in main.xsl file is utilized in CTXGeneration template:

<!–
Partial implementation of CTXGeneration template
(The remaining code is omitted for clarity here)
–>
<xsl:template name="CTXGeneration" ddwrt:ghost="always">
<script type="text/javascript">
ctx = new ContextInfo();
<!–Save List Dialogs parameter in NavigateForFormsPages property of ContextInfo structure–>
ctx.NavigateForFormsPages = <xsl:choose>
<xsl:when test="$NavigateForFormsPages='1'">true</xsl:when>
<xsl:otherwise>false</xsl:otherwise>
</xsl:choose>;
ctx<xsl:value-of select="$ViewCounter"/> = ctx;
g_ctxDict['ctx<xsl:value-of select="$ViewCounter"/>'] = ctx;
</script>
</xsl:template>

view raw
CTXGeneration.xsl
hosted with ❤ by GitHub

This template is intended for rendering  extra information about List settings on the client side  (ContextInfo structure). It is invoked every time when the List View is rendered on page. Pay attentions that List Dialogs setting that corresponds to NavigateForFormsPages property of ContextInfo structure.

And finally the event handler of the List form links is as follows:

//Handler for List form links in SharePoint 2010
// (from CORE.js)
function _EditLink2(elm, ctxNum)
{ULSrLq:;
var fn=function()
{ULSrLq:;
var url=GetGotoLinkUrl(elm);
if (url==null)
return;
var ctxT=window["ctx"+ctxNum];
if (ctxT !=null && ctxT.clvp !=null)
{
var clvp=ctxT.clvp;
if (FV4UI() && !ctxT.NavigateForFormsPages) //check if Dialogs option (NavigateForFormsPages property of ContextInfo) is set to 'No'
{
PreventDefaultNavigation();
clvp.ShowPopup(url); //open form in modal dialog boxes
return false;
}
}
GoToLink(elm); //navigate using href attribute of link
}
EnsureScript("inplview", typeof(inplview), fn);
}

view raw
_EditLink2.js
hosted with ❤ by GitHub

How the List Form link should be handled is determined by the NavigateForFormsPages parameter in the specified function, i.e. :

  • by navigating to a full page using href attribute of link
  • display form in modal dialog box

List Dialogs setting in ListViewWebPart

Now it is time to return to the question about why this settings is not available on all the forms. For answering on that question let me step back and explain a little bit about rendering a List View. Up until now we were talking only about rendering a List View via XsltListViewWebPart  that  handles view rendering for default lists, such as document libraries and announcements. But what about ListViewWebPart that is used for rendering specific List Views like  Calendar, Gantt or Chart Views.

The point is that this parameter (List Dialogs) does not take into account when a List View is rendered via ListViewWebPart. And the message “Dialogs that may not be available on all forms” concerns exactly this situation.

Then the question arise, how do we deal with the case where we need to open List Forms as a full pages for ListViewWebPart?  Let’s consider a real-world example when we need a Calendar forms to be opened as a full pages.

There are several ways how to achieve it, but we will consider only one, one of the simplest. The idea is to specify explicitly NavigateForFormsPages parameter for ContextInfo structure.

Steps:

1. Add CEWP into Calendar View page (Calendar.aspx)

2.  Place the following JavaScript code into CEWP

//Additional properties for ContextInfo () to be utilized in Calendar List View
//Specify actions navigate to the full page
var ContextInfo = (function() {
var ContextInfo_Orig = ContextInfo;
return function() {
ContextInfo_Orig();
this.NavigateForFormsPages = true; // Set navigate to the full page for list forms links
}
})();

That’s all, after that the Calendar forms will be opened as a full pages.