SharePoint 2013: How to open list forms in dialog box instead of navigating to another page.

SharePoint 2013: How to open list forms in dialog box instead of navigating to another page.



In SharePoint 2010, when you try to add new item to list, edit item or view item dialog box gets opened. And once you have done with the action you remain on the same page, so minimal to and fro navigation
.But in SharePoint 2013, you get navigated to another page and once completing action you get back to page or you need to navigate back yourself.  

But what if you have migrated your application from 2010 to 2013 and now end user wants the dialog box instead of navigating to another page? No need to worry, SharePoint has provided you option to choose either dialog box or 2013 behavior.


Steps to force to open the dialog box for list forms:

      1.  Go to the List/ library Settings

            
            

    2.    Now go to the advanced settings, scroll down and go to the ‘Dialogs’ Section. Select “Yes”

               


  3.  Click Ok and you done. Now you can see list forms get opened in dialog box as shown in below screen shot.

            

About Calendar List

Now one thing about the calendar list I have noticed: Once you enable the Dialog box for calendar list all forms (new, edit and view) gets opened in dialog box; for opening the view form in dialog box you need to click on the box of meeting and then View button from ribbon box. But what users do here is they click directly on the hyper link which shows the title of meeting and they get navigated to another page. We cannot say it as bug because we have to click on box rather than title but it is human tendency: click on hyper link wherever it appears. J

Now what you will do to avoid navigation to another page even clicked on hyper link or title? Use below JavaScript code snippet. Note: this is working only for Month View; you need to customize it for other views. 
 
<script src="/jquery-1.9.1.js"></script>
  
<script type="text/javascript">
  
function openDialogBox(Url) 
{    
    var ModalDialogOptions = { url:Url, width: 600, height: 500, showClose: true, allowMaximize: true};    
      
    SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', ModalDialogOptions);
}
  
  
$('.ms-acal-month').ready(function () { 
  
setTimeout(function() {
  
$('a[href*="DispForm.aspx"]').each(function() {
$(this).attr('onclick', 'openDialogBox("' +  $(this).attr('href') + '")');
//$(this).attr('onclick', ' ');
//alert($(this).attr('href'));
});
  
$('a[href*="DispForm.aspx"]').each(function() {
$(this).attr('href','javascript:openDialogBox("' +  $(this).attr('href') + '")');
});
  
}, 3000);
});
  
</script>

What this code snippet does here is, it finds all meeting titles which are hyperlinks on the Month view and changes href attribute to call ‘openDialogBox’ JavaScript method. And ‘openDialogBox’ opens the page in dialog box.

In this way you can use dialog boxes to show forms in SharePoint 2013.

Leave a Comment
  • Please add 7 and 7 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
  • Balaji M Kundalam edited Revision 6. Comment: Removed extra spaces.

  • Maheshkumar S Tiwari edited Revision 5. Comment: Added tags and minor formatting

  • Rahul A Shinde edited Revision 2. Comment: TOC added

Page 1 of 1 (3 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
  • Rahul A Shinde edited Revision 2. Comment: TOC added

  • Maheshkumar S Tiwari edited Revision 5. Comment: Added tags and minor formatting

  • Balaji M Kundalam edited Revision 6. Comment: Removed extra spaces.

Page 1 of 1 (3 items)