1

我需要使用 JSOM 或 Rest 在 SharePoint Online 中更改列表视图的字段顺序。感谢有人能指出我正确的方向。

4

1 回答 1

0

检查下面的线程以通过 JSOM 更新列表视图。

<script type="text/ecmascript" language="ecmascript">

function runCode() {

    var clientContext = new SP.ClientContext.get_current();

    if (clientContext != undefined && clientContext != null) {
        var web = clientContext.get_web();

        var listCollection = web.get_lists();
        var list = listCollection.getByTitle("Tasks");
        var viewCollection = list.get_views();
        var view = viewCollection.getByTitle("All Tasks");

        var query = '<OrderBy><FieldRef Name=\'Title\' Ascending=\'False\' /></OrderBy>';

        view.set_viewQuery(query);
        view.update();

        clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
    }
}

function onQuerySucceeded() {
    alert('Tasks list ordered in descending alphabetic order.');
}

function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

https://msdn.microsoft.com/en-us/library/office/jj245986.aspx

于 2018-03-06T05:21:27.390 回答