
[英]How to manually set the page and total results on first load of Kendo UI Grid attached to a remote dataSource (autoBind:false)?
[英]How to pass page number to kendo datasource, so it could load data of page 2?
以下代码构建了我的kendo DataSource:
var dataSource = new kendo.data.DataSource({
serverPaging: true,
schema: {
data: "ListMediaSummary",
total: "RowCount",
},
transport: {
read: {
url: gAppBaseURL + "UniversalSearch/SearchData?searchText=" + searchText + "&pageNumber=" + page,
type: "POST",
dataType: "json",
}
},
parameterMap: function (data, type) {
if (type == "read") {
return {
$top: data.take,
$skip: data.skip
}
}
},
page: 1,
pageSize: 25,
});
然后从这里,我将来自transport.read方法的参数“ searchText”和“ PageNumber”传递给我的asp.net控制器中的Action方法,然后将搜索结果呈现到kendo listView中。 操作方法获取“ searchText”值,但获取pageNumber吗? 虽然在帖子中它确实传递了页码(在firebug中检查),但是我想要的是将页码传递给函数中的transport.read方法。 我怎样才能做到这一点?
要启用服务器分页,应将数据源配置为启用serverPaging
。 然后,数据源将把数据项分页实现留给远程服务。 默认情况下,数据源执行客户端的页面调度。
<script>
var dataSource = new kendo.data.DataSource({
transport: {
/* transport configuration */
},
serverPaging: true,
schema: {
total: "total" // total is returned in the "total" field of the response
}
});
</script>
如果将serverPaging设置为true,请不要忘记设置schema.total。
启用服务器分页时,以下选项将发送到服务器:
因此,您应该将控制器操作方法更改为如下所示:
public ActionResult GetData(int page, int pageSize, int skip, int take){
// do some magic operation
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.