我正在尝试使用SharePoint读取列表属性,但没有成功。
任何人都可以帮助--这是用get_fieldValues和get_item方法尝试的代码,并且都返回了“未定义”。
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.');
}发布于 2016-02-25 08:44:18
试试这个:
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.');
}https://stackoverflow.com/questions/35620733
复制相似问题