我使用下面的代码创建了列表视图
ViewCreationInformation creationInfo = new ViewCreationInformation();
creationInfo.Title ="MyView";
creationInfo.RowLimit = 10;
creationInfo.ViewFields = viewFields.ToArray();
creationInfo.ViewTypeKind = "HTML";
viewCollection.Add(creationInfo);
context.ExecuteQuery();
我想使用CSOM更改样式。但是没有选择使用客户端DLL更改样式。虽然我尝试更新ListViewXML没有得到更新。请帮助我。
答案 0 :(得分:0)
/////请在下面的代码中添加您的代码
/////更新视图样式
/*
* 0-Basic Table
* 14-Document Details
* 15-Newsletter
* 16-Newsletter, no lines
* 17-Shaded
* 20-Preview Pane
*/
ViewCollection oView = list.Views;
int styleId = 17;
foreach (View v in oView)
{
if (v.Title == "MyView")
{
ctx.Load(v);
ctx.ExecuteQuery();
XmlDocument doc = new XmlDocument();
doc.LoadXml(v.ListViewXml);
XmlElement element = (XmlElement)doc.SelectSingleNode("//View//ViewStyle");
if (element == null)
{
element = doc.CreateElement("ViewStyle");
element.SetAttribute("ID", styleId.ToString());
doc.DocumentElement.AppendChild(element);
}
else
{
element.SetAttribute("ID", styleId.ToString());
}
v.ListViewXml = doc.FirstChild.InnerXml;
v.Update();
ctx.ExecuteQuery();
break;
}
}