我有两个清单.公司和员工.我在员工列表中有一个名为"company"的查找列,该列指向员工的ID.
在我的REST查询中,我可以非常轻松地扩展公司的标题
http://abhi-sharepoint.abhishek.com/sites/dev/_api/web/lists/getbytitle('Employee')/items?$select=ID,Title,Company/Title&$expand=Company/Id&$filter=Company/Id%20eq%20%2714%27
Run Code Online (Sandbox Code Playgroud)
很好!
现在,我将另一个查找列添加到名为Manager的Employee List中,并将其指向employee id
现在我如何将ManagerId扩展为经理头衔?
我试过了
http://abhi-sharepoint.abhishek.com/sites/dev/_api/web/lists/getbytitle('Employee2')/items?$select=ID,Title,Employee2/Title,Company/Title&$expand=Company/Id&$expand=Manager/Id&$filter=Company/Id%20eq%20%2714%27
Run Code Online (Sandbox Code Playgroud)
我也试过了
http://abhi-sharepoint.abhishek.com/sites/dev/_api/web/lists/getbytitle('Employee2')/items?$select=ID,Title,Employee2/Title,Company/Title&$expand=Company/Id&$expand=Employee2/Id&$filter=Company/Id%20eq%20%2714%27
Run Code Online (Sandbox Code Playgroud)
但没有任何作用.如何在同一列表中使用展开?
以下REST端点
/_api/web/lists/getbytitle('Employee')/items?$select=Title,Company/Title,Manager/Title&$expand=Company/Id,Manager/Id
Run Code Online (Sandbox Code Playgroud)
返回Employee Title,Company Title并且Manager Title,其中Managerfield是Lookup同一个List的a
例:
var query = "/_api/web/lists/getbytitle('Employee')/items?$select=Title,Company/Title,Manager/Title&$expand=Company/Id,Manager/Id";
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + query,
type: "GET",
headers: { "ACCEPT": "application/json;odata=verbose" },
success: function(data){
$.each(data.d.results, function(idx,item){
console.log(item.Title); //Employee Title
console.log(item.Company.Title); //Company Title
console.log(item.Manager.Title); //Manager Title
});
},
error: function(data){
console.log(JSON.stringify(data));
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4087 次 |
| 最近记录: |