使用jQuery搜索REST Api中的结果分页 [英] Pagination for results in search REST Api with jQuery

查看:82
本文介绍了使用jQuery搜索REST Api中的结果分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下午好,对于REST API调用的结果实施分页的最佳方法是什么?我一直在尝试使用发送到API的查询中的rowlimit,startrow和rowsperpage属性进行调用,但我看不到任何更改。我正在使用
只需jQuery和REST API调用即可完成此操作。


这是发送给API服务的查询:


var searchURL = _spPageContextInfo.webAbsoluteUrl +" / _ api / search / query?queryText ='" + query +"'& rowlimit = 500& startrow = 0& RowsPerPage = 10& enableSorting = true";


正如您在图片底部看到的,我想要根据下拉列表中选择的每页项目值来实现链接以浏览页面,我猜这将是RowsPerPage属性值,这是正确的吗?


任何帮助都将是感谢,提前谢谢。







Carlos M

解决方案

< blockquote>


在搜索REST API中使用startrow和rowlimit。了解有关
的更多信息
SharePoint搜索REST API


例如:

函数搜索(queryText,rowLimit,startRow,allResults)

{

var allResults = allResults || [];

var url = _spPageContextInfo.siteAbsoluteUrl +" / _ api / search / query?querytext ='" + queryText +"'& rowlimit =" + rowLimit +"'& startrow =" + startRow +"& sortlist ='LastModifiedTime:ascending" ;;

return


.getJSON(url).then(function(data){

var relevantResults = data.PrimaryQueryResult.RelevantResults;

allResults = allResults.concat(relevantResults.Table.Rows);

if(relevantResults.TotalRows> startRow + relevantResults.RowCount){

返回搜索(queryText,rowLimit,startRow + relevantResults.RowCount,allResults);

}

返回allResults;

});

}





调用上面的搜索功能单击按钮时。


例如:

 search(_spPageContextInfo.webAbsoluteUrl,'sharepoint',100,0)

.done(函数(结果){

for(var i = 0; i< results.length; i ++){

//做某事......

}

});





演示关于如何通过分页获得搜索结果:


https://sharepoint.stackexchange.com/questions/208462/sharepoint-search-js-returns-only-500-search-results/208468


< p style ="margin-bottom:12.0pt;行高:125%; background:white"> Best  respect,


Linda 张


Good afternoon, what would be the best approach to implement pagination for the results from REST API call? I have been trying to make the call using rowlimit, startrow and rowsperpage properties in the query sent to the API but I see no change. I'm using just jQuery and REST API calls to accomplish this.

This is the query sent to the API service:

var searchURL = _spPageContextInfo.webAbsoluteUrl + "/_api/search/query?queryText='" + query + "'&rowlimit=500&startrow=0&RowsPerPage=10&enableSorting=true";

As you can see at the bottom of the image, I would like to implement the links to navigate through the pages based on the items per page value selected in the dropdown list which I guess would be the RowsPerPage property value, is that correct?

Any help would be appreciated, thanks in advance.



Carlos M

解决方案

Hi,

Use startrow and rowlimit in search REST API. Learn more about SharePoint Search REST API.

For example:

function search(queryText,rowLimit,startRow,allResults)

{

    var allResults = allResults || [];

    var url = _spPageContextInfo.siteAbsoluteUrl + "/_api/search/query?querytext='" + queryText + "'&rowlimit=" + rowLimit + "'&startrow=" + startRow + "&sortlist='LastModifiedTime:ascending";

    return


.getJSON(url).then(function(data) { var relevantResults = data.PrimaryQueryResult.RelevantResults; allResults = allResults.concat(relevantResults.Table.Rows); if (relevantResults.TotalRows > startRow + relevantResults.RowCount) { return search(queryText,rowLimit,startRow+relevantResults.RowCount,allResults); } return allResults; }); }


Call the above search function when clicking the button.

For example:

search(_spPageContextInfo.webAbsoluteUrl,'sharepoint',100,0)

  .done(function(results){

       for(var i = 0;i < results.length;i++){

           //do something…

       }

   });


Demo about how get search results with pagination:

https://sharepoint.stackexchange.com/questions/208462/sharepoint-search-js-returns-only-500-search-results/208468

Best regards,

Linda Zhang


这篇关于使用jQuery搜索REST Api中的结果分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆