我正在尝试为SharePoint列表视图web部件设置工具栏。我可以在SSOM中做到这一点,但在CSOM中不能。我尝试过更新列表视图the部件的XMLDefinition属性中的Toolbar类型元素。但它不起作用。我还试着获得MethodInfo,如下所示。
Type[] toolbarMethodParamTypes = { Type.GetType("System.String") };
MethodInfo setToolbarTypeMethod = webpartView.GetType().GetMethod("SetToolbarType", BindingFlags.Instance | BindingFlags.NonPublic, null, toolbarMethodParamTypes, null);但它返回null。
有什么替代方法可以实现这一点吗?
发布于 2017-08-24 20:25:29
没有使用CSOM设置工具栏的直接方法。因此,我们决定使用Jquery设置工具栏。我已经在the部件代理的JSLink中添加了以下脚本。
function hideToolbar(renderCtx) {
var toolbar=renderCtx.viewTitle;
if(toolbar != "")
{
if(toolbar=="None")
renderCtx.ListSchema.Toolbar="None";
else if(toolbar=="Freeform")
renderCtx.ListSchema.Toolbar="Freeform";
}
}
(function () {
var overrideContext = {};
overrideContext.Templates = {};
overrideContext.OnPreRender = hideToolbar;
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideContext);
})();当网页部件添加到页面中时,我已经在我的CSOM代码中设置了ViewTitle。
https://stackoverflow.com/questions/44923936
复制相似问题