Tuesday 12 April 2016

Open display form in Sharepoint Dialog using CSOM

In one of my project we got a requirement to show the display form of list item in popup same as default dialog in sharepoint. we have used JSOM to dispaly all the items of a list in specific design. On clicking on Read More link we need to display the popup.

Solution:

function ShowInModal(dispTitle, pageUrl) {  
             var viewportWidth = $(window).width();
             var viewportHeight = $(window).height();
             var options = {
                url: pageUrl,
                title: ''+dispTitle,
                width: viewportWidth * 0.7,
                height: viewportHeight * 0.8 
             };
             SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
          } 


<a href="javascript: void(0);" onclick="ShowInModal('DialogName','SiteUrl/Lists/ListName/DispForm.aspx?ID={{:ID}}&IsDlg=1');" alt="">read more</a>

No comments:

Post a Comment