【问题标题】:SharePoint Online - Show/display column in default viewSharePoint Online - 在默认视图中显示/显示列
【发布时间】:2018-04-07 11:44:02
【问题描述】:

我正在将网站栏添加到文档库默认视图中,并希望在您单击列表本身时显示/显示它。但是,我不确定如何执行此操作。我到目前为止的代码

// Get the view (this is the default view)  
Microsoft.SharePoint.Client.View v = Employeecvlist.GetViewByName("All Documents");

// Load it up
clientContext.Load(v, x => x.ViewFields);
clientContext.ExecuteQuery();

// Get the field I want to add to the view
Microsoft.SharePoint.Client.Field name = 
Employeecvlist.Fields.GetByInternalNameOrTitle("Name");

clientContext.Load(name);
clientContext.ExecuteQuery();

// Add this field to the view !! Nothing else in the view object to allow to make it visible by default !!
v.ViewFields.Add(name.InternalName);

// Finally, update the view
v.Update();

如果您查看下面的图像文件,我基本上希望能够将上述字段的“显示”复选框选中为真。

有人能指出我正确的方向吗?

谢谢

【问题讨论】:

    标签: sharepoint sharepoint-online csom


    【解决方案1】:

    您需要再次执行clientContext.ExecuteQuery() 以保留更改。此外,无需执行两次即可加载对象、加载所需的所有内容然后从服务器获取:

    //Put following line in the using section
    using Microsoft.SharePoint.Client;
    
    //Your code
    View v = Employeecvlist.GetViewByName("All Documents");
    Field name = Employeecvlist.Fields.GetByInternalNameOrTitle("Name");
    
    clientContext.Load(v, x => x.ViewFields);
    clientContext.Load(name);
    
    v.ViewFields.Add(name.InternalName);
    v.Update();
    
    clientContext.ExecuteQuery();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-12
      • 2021-03-12
      • 2021-01-16
      • 1970-01-01
      • 2018-05-07
      • 2011-11-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多