JQGrid是否可以与SharePoint结果源REST API一起使用

问题描述

我试图通过使用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-8,fx返回。

但是当我在Jqgrid中使用它时,在第44行出现错误:未捕获的TypeError:无法读取未定义的属性'length'

$。ajax({url:apiUrl,type:“ GET”,async:false,标头:{“ accept”:“ application / json; odata = verbose”},成功: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&id&$ select = Name,ItemCount,ListItemAllFields / AuthorId,ListItemAllFields / ExaminiName PublishedDate1&$ filter =名称为'Forms'和ItemCount gt 0“;

解决方法

enter image description here

  1. 您应该检查rest api是否正确返回值。
  2. 检查使用length的变量的类型是否具有length属性。
,

它起作用了,我弄清楚了。SharePoint搜索api本身仅提供Filename,ContentTypeID和Path。我使用这些值来运行另一个api调用以获取元数据,然后将这些值添加到用于馈送jqgrid的数组中。

只需将所有数据放入数组中,然后在数据准备就绪时将其馈送到jqgrid。