javascript - SharePoint 2013 In allitems.aspx How Do I get the list title and Name -



javascript - SharePoint 2013 In allitems.aspx How Do I get the list title and Name -

i trying mimic alert me functionality business wants alert me , send link. in alert me trying current list's name , title when javascript code in allitems.aspx page of document library. of examples can find assume know title of list already.

at to the lowest degree next options used determine list properties (like title) in list view page (allitems.aspx)

using sp.listoperation.selection namespace

sp.listoperation.selection.getselectedlist() method gets id of list beingness selected:

var listid = sp.listoperation.selection.getselectedlist();

the next illustration demonstrates how retrieve list id via csom (javascript):

(function(){ var listid = sp.listoperation.selection.getselectedlist(); //selected list id var context = new sp.clientcontext.get_current(); var web = context.get_web(); var list = web.get_lists().getbyid(listid); context.load(list); context.executequeryasync( function() { //print list properties console.log(list.get_title()); }, function(sender,args){ console.log(args.get_message()); } ); })(); using _sppagecontextinfo structure

_sppagecontextinfo object rendered in every sharepoint page , contains property _sppagecontextinfo.pagelistid stores current list id:

var listid = _sppagecontextinfo.pagelistid;

javascript sharepoint

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -