作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
正如标题所说,我需要一种方法来以编程方式编辑 Sharepoint 2010 中列表的现有 View 。我发现了很多关于创建新 View 的示例:
SPList documents = web.Lists["Documents"];
StringCollection fields = new StringCollection();
fields.Add("Type");
fields.Add("Name");
fields.Add("File Size");
fields.Add("Modified");
fields.Add("Modified By");
fields.Add("Version");
var query = new XElement("Where",
new XElement("Eq",
new XElement("FieldRef", new XAttribute("Name", "Project")),
new XElement("Value", new XAttribute("Type", "Lookup"), "alpha")
)
).ToString(SaveOptions.DisableFormatting);
SPView view = documents.Views.Add(
"ProjectFilter",
fields,
query,
100,
false,
false,
Microsoft.SharePoint.SPViewCollection.SPViewType.Html,
false);
我还找到了一些关于根据显示字段编辑现有列表的示例:
SPList documents = web.Lists["Documents"];
SPview view = documents.Views["All Documents"];
view.ViewFields.Add("Price");
view.Update();
我唯一没有找到的方法是修改现有 View 并使用 CAML 查询对其进行过滤,就像我创建它时上面的示例一样
有办法吗?
最佳答案
好的,这是解决方案!
SPList documents = web.Lists["Documents"];
SPView docview = documents.Views["Project Filtered"];
var docquery = new XElement("Where",
new XElement("Eq",
new XElement("FieldRef", new XAttribute("Name", "Project")),
new XElement("Value", new XAttribute("Type", "Lookup"), "alpha")
)
).ToString(SaveOptions.DisableFormatting);
docview.Query = docquery;
docview.Update();
关于visual-studio-2010 - 共享点 2010 : edit a view programmatically,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3942225/
我是一名优秀的程序员,十分优秀!