首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SharePoint Ecma获取列表属性

SharePoint Ecma获取列表属性
EN

Stack Overflow用户
提问于 2016-02-25 07:16:15
回答 1查看 152关注 0票数 0

我正在尝试使用SharePoint读取列表属性,但没有成功。

任何人都可以帮助--这是用get_fieldValues和get_item方法尝试的代码,并且都返回了“未定义”。

代码语言:javascript
复制
var key = "vti_level";
function getListProperty() {
    var clientContext = new SP.ClientContext();
    var listGuid = GetUrlKeyValue('List', window.location.href);
    this.props = clientContext.get_web().get_lists().getById(listGuid).get_rootFolder();
    clientContext.load(this.props);
    clientContext.executeQueryAsync(Function.createDelegate(this, getListPropertySuccess), Function.createDelegate(this, getListPropertyFailed));
}

function getListPropertySuccess() {
    var propKey1 = this.props.get_properties().get_fieldValues()[key];
    var propKey2 = this.props.get_properties().get_item(key);
}

function getListPropertyFailed() {
    alert('Request failed on getListProperty.');
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-02-25 08:44:18

试试这个:

代码语言:javascript
复制
    var key = "vti_level";

        function getListProperty() {
            var clientContext = new SP.ClientContext();
            var listGuid = _spPageContextInfo.pageListId;
            this.props = clientContext.get_web().get_lists().getById(listGuid).get_rootFolder().get_properties();
            clientContext.load(this.props);
            clientContext.executeQueryAsync(Function.createDelegate(this, getListPropertySuccess), Function.createDelegate(this, getListPropertyFailed));
    }
    function getListPropertySuccess() {
        var propKey1 = this.props.get_fieldValues()[key];
        var propKey2 = this.props.get_item(key);
    }
    function getListPropertyFailed() {
        alert('Request failed on getListProperty.');
    }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35620733

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档