简体   繁体   English

使用 Ajax 时如何在自定义列表上显示查找字段

[英]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.

相关问题 使用ajax显示列表 - Display list using ajax 如何使用Ajax从#facebook graph url查找返回的json对象获取特定字段 - How to get particular field from a json object returned by # facebook graph url lookup using ajax 如何使用 Xrm Web Api 更新 Microsoft 模型驱动应用程序中的自定义查找字段? - How to update a custom lookup field in a Microsoft Model-driven App using the Xrm Web Api? 如何使用Ajax从下拉列表中使用JQuery显示.php文件? - How to display a .php file with Ajax using JQuery from a dropdown list? 如何使用jquery ajax从复选框列表显示项目 - How to display items from checkbox list using jquery ajax 如何解决查找字段自定义过滤中的查询生成器错误? - How to resolve Query Builder Error in custom filtering of Lookup field? 列表中的值为空时如何显示自定义消息 - How to display custom message when the value in the list is null 选择项目时如何使用Ajax将数据提取到输入字段中 - How to fetch data into input field using ajax when an item is selected 成功使用ajax发送帖子值时如何显示此div? - How to display this div when success send post value using ajax? 如何在使用Rickshaw.Graph.Ajax时显示数据 - How to display data when using Rickshaw.Graph.Ajax
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM