create a custom menu ina lisviewbyquery web part in SP 2013

Yesterday client had asked us to create a  custom menu item in listviewbyquery web part. The  listviewbyquery web part was shown to the users with documents populated from multiple site collections and sub sites.

so  i was able to create with a custom menu item in the listviewbyquery web part so that when clicked on that a modal pop up [aspx ] /sp dialog  was populated.

<script language=”javascript”>
 
function Custom_AddDocLibMenuItems(m, ctx)
 
{
    

 //Add your Menu Name which you want to display
 
   var strDisplayText = “Add Reference”;

// parse the URL out of the itemTable
 
var URL = “”;
 
var index = itemTable.innerHTML.indexOf(“href=”);
 
if (index > 0)
 
{
 
  var str = itemTable.innerHTML.substr(index + 6);
 
  index = str.indexOf(‘”‘);
 
  if (index > 0)
 
  {
 
    URL = str.substr(0, index);

//  alert(URL);
 
 
  }
 
}
 
  var strAction = “javascript:OpenDialog(‘http://mysrvename:5182/_layouts/15/myLink/mylinkCustAction.aspx?docpath=&#8221; + URL + “‘)”;
   
  var strImagePath = “”;
 
 
 // Add our new menu item

  CAMOpt(m, strDisplayText, strAction, strImagePath);
 
  // add a separator to the menu
 
  CAMSep(m);
 
  // false means that the standard menu items should also be rendered
  // if you set true, it will show only the menu which you added( standard sharepoint menu items will not be available.
  // you can control by setting the value of true or false
  return false;

}
</script>

<script type=”text/javascript”> 
 function OpenDialog(myurl)
 {       
    var options = SP.UI.$create_DialogOptions();     
    options.url = myurl;   
      options.width = 250;  options.height = 250;  
     //options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback); 
       SP.UI.ModalDialog.showModalDialog(options); 
 }
</script>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s