【发布时间】:2020-09-27 20:24:41
【问题描述】:
我尝试通过使用 REST API 查询 SharePoint 结果源来查看是否可以使用 JQGrid 显示 SharePoint 搜索结果。
使用 REST API 调用结果源的代码在浏览器和 Postman 中工作:
var apiUrl =_spPageContextInfo.webAbsoluteUrl +/_api/search/query?querytext='Mike'&rowlimit=100&selectproperties='RequestNameOWSTEXT, SubmittedByOWSUSER,ExaminiationNameOWSTEXT,PublishedDate1OWSDATE&sourceId='d90c19xx-7b3x-42bx-8fbx-d1dxxxx543ffa7', 许多结果返回。
但是当我在 JQGrid 中使用它时,在第 44 行出现错误:Uncaught TypeError: Cannot read property 'length' of undefined
$.ajax({ url: apiUrl,type: "GET", async: false, headers: { "accept": "application/json;odata=verbose" }, success: function (data) {
第 44 行:$.each(data.d.results, function (index, value) { ................... ..
我猜 api 调用没有返回结果,所以数据是未定义的。想知道那个 api 有什么问题吗?
如下所示的不同 api 可以返回结果:
var apiUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/GetFolderByServerRelativeUrl('documentrequest')/Folders?$expand=ListItemAllFields,AuthorID/id&$select=Name,ItemCount,ListItemAllFields/AuthorId,ListItemAllFields/ExaminiationName,ListItemAllFields/ PublishedDate1&$filter=Name ne 'Forms' and ItemCount gt 0";
【问题讨论】:
-
请分享使用错误代码中提到的长度属性的代码。
-
也将整个jqGrid设置和相关功能分享给它。
-
代码失败,api使用结果源,返回未定义,猜测api调用没有结果。 jqGrid 设置与之前的 api 相同。以前的 api 工作: var apiUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/GetFolderByServerRelativeUrl('documentrequest')/Folders?$expand=ListItemAllFields,AuthorID/id&$select=Name,ItemCount,ListItemAllFields/SubmitterName,ListItemAllFields/ExamName,ListItemAllFields /PublishedDate1,&$filter=Name ne 'Forms' and ItemCount gt 0";
-
需要使用results = data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results从搜索结果文档集中检索数据在JGGrid中显示就好了但是附件没有显示在jqgrid
-
RequestNameOWSTEXT, SubmittedByOWSUSER,ExaminiationNameOWSTEXT,PublishedDate1OWSDATE 是可查询的托管属性,但搜索 api 调用没有返回值。 search api 调用返回系统列,如 contenttypeId、文件名、路径,但不返回自定义列值。
标签: sharepoint jqgrid