【问题标题】:sharepoint 2013 - use CSOM to change the view sort columnsharepoint 2013 - 使用 CSOM 更改视图排序列
【发布时间】:2014-10-31 22:31:41
【问题描述】:

我有一个列表,在其默认视图(所有项目)中,默认按 ID 排序,我需要使用 CSOM 将排序列更改为“标题”列,我该怎么做?

【问题讨论】:

    标签: sharepoint csom


    【解决方案1】:

    如何通过 CSOM 设置视图排序:

    var pagesList = ctx.Web.Lists.GetByTitle("Pages");
    var view = pagesList.DefaultView;
    view.ViewQuery = CreateOrder("Title",true);
    view.Update();
    ctx.ExecuteQuery();
    
    
    public static string CreateOrder(string fieldName, bool ascending)
    {
        return string.Format("<OrderBy><FieldRef Name=\"{0}\" Ascending=\"{1}\" /></OrderBy>", fieldName, ascending ? "TRUE" : "FALSE"); 
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-07
      • 2017-10-11
      • 1970-01-01
      • 2016-01-03
      • 1970-01-01
      • 1970-01-01
      • 2021-02-27
      • 1970-01-01
      相关资源
      最近更新 更多