[英]How to display a lookup field on a custom list when using Ajax
I have a script that calls a custom list and displays information to the SharePoint page.我有一个调用自定义列表并将信息显示到 SharePoint 页面的脚本。 I'm able to get the information, but not able to display the Section attribute.我能够获取信息,但无法显示 Section 属性。 Section is an object.节是一个对象。 Section is a Lookup to another custom list on my site.部分是对我网站上另一个自定义列表的查找。 Here is my code:这是我的代码:
$(document).ready(function() {
loadItems();
});
function loadItems() {
console.log("loadItems ...");
var siteUrl = _spPageContextInfo.siteAbsoluteUrl;
var oDataUrl = siteUrl + "/_api/web/lists/getbytitle('Contacts')/items?$select=Title,Organization,Section/Title,Business_x0020_Phone,Created&$expand=Section";
$.ajax({
url: oDataUrl,
type: "GET",
dataType: "json",
headers: {
"accept": "application/json;odata=verbose"
},
success: mySuccHandler,
error: myErrHandler
});
}
function mySuccHandler(data) {
try {
console.log("Success loading");
$('#table_id').DataTable({
"aaData": data.d.results,
"aoColumns": [
{
"mData": "Title"
},
{
"mData": "Organization"
},
{
"mData": "Section"
},
{
"mData": "Business_x0020_Phone"
},
{
"mData": "Created"
}
]
});
} catch (e) {
alert(e.message);
}
}
function myErrHandler(data, errMessage) {
console.log("Error: " + errMessage);
}
What should the syntax be for displaying the Section?显示部分的语法应该是什么?
For Objects, I need to use the following syntax:对于对象,我需要使用以下语法:
{
"mDataProp": "Section.Title"
}
Instead of代替
{
"mData": "Section"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.