SharePoint Online - 默认视图中的 Show/display 列

SharePoint Online - Show/display column in default view

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

// 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();

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

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

谢谢

您需要再次执行 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();