Not able to modify the toolbar using CSOM in a webpart


we trying modify toolbar details of custom list using csom. however, couldn't find option modify toolbar of web-part in page. toolbar property of webpart read-only property in csom , hence cannot modify it.
 we have make toolbar=none.

  can please let know if there solutions hide toolbar in web-part using csom.?

hi,

the webpart doesn't has property setting toolbar type view does.

as workaround, can use css hide toolbar in list view web part.

<style type="text/css"> #hero-wpq2{     display:none !important; } </style>

or can set jslink property of web part, , use use jslink hide toolbar.

to set jslink property, following code reference:

string targetsiteurl = @"https://milesli.sharepoint.com/sites/dennis"; var login = "***@***.onmicrosoft.com"; var password = "***"; var listname="customlist"; var securepassword = new securestring();  foreach (char c in password) {     securepassword.appendchar(c); } sharepointonlinecredentials onlinecredentials = new sharepointonlinecredentials(login, securepassword);  clientcontext context = new clientcontext(targetsiteurl); context.credentials = onlinecredentials; list list = context.web.lists.getbytitle(listname); context.load(list); context.load(list.views); context.executequery();  foreach (var view in list.views) {     if (view.serverrelativeurl.contains("allitems.aspx"))     {         microsoft.sharepoint.client.file file = context.web.getfilebyserverrelativeurl(view.serverrelativeurl);         limitedwebpartmanager wpm = file.getlimitedwebpartmanager(personalizationscope.shared);         context.load(wpm.webparts, wps => wps.include(wp => wp.webpart.title));         context.executequery();          //set properties web parts         foreach (webpartdefinition wpd in wpm.webparts)         {             webpart wp = wpd.webpart;             wp.properties["jslink"] = "~site/lib/hidetoolbar.js";             wpd.savewebpartchanges();             context.executequery();         }     } }

best regards,

dennis guo


technet community support
please remember mark replies answers if help, , unmark answers if provide no help. if have feedback technet support, contact tnmff@microsoft.com.



SharePoint  ,  Apps for Office and SharePoint  >  Developing Apps for SharePoint 2013



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'