我尝试了各种方法来设置Kendo-UI Web Grid
中的记录总数,但没有成功。
我有点迷失在我在ajax中处理金额的地方,已经在模式中分配4的总值,看看是否发生更多分页不起作用,只显示两条记录,它显示那里是更多的页面。
如果有人能帮助我,我将非常感激!
...
transport: {
read: function (option) {
$.ajax({
url: '<?=$view->encode('ctrl.php?turma=lista_turma');?>',
data:{
skip: option.data.skip,
take: option.data.take,
pageSize: option.data.pageSize,
page: option.data.page,
sorting: JSON.stringify(option.data.sort),
filter: JSON.stringify(option.data.filter)
},
success: function (result) {
option.success(JSON.parse(result));
},
error: function (result) {
alert(result);
}
},
schema: {
data: 'data',
total: function (data) {
return 4;
},
/*total: function (result) {
alert('aqui');
result = result.d || result;
return 4;
},*/
model: { id: "id_turma" },
fields: {
id_turma: { validation: { required: true } },
nome_turma: { validation: { required: true } },
sigla_turma: { validation: { required: true, max:12 } }
}
}
},
pageable: true,
serverPaging: true,
serverFiltering: true,
serverSorting: true,
batch: true,
pageSize: 2
});
答案 0 :(得分:2)
我不确定您要对代码中的所有“eval”语句执行什么操作。这看起来很复杂。
如果进行服务器端分页,则应从服务器返回总数,因为客户端通常不知道有多少记录。如果您的回复包含属性“total”,那么这应该有效:
schema: {
total: "total" // total is returned in the "total" field of the response
}
或者,如果你想使用一个函数:
schema: {
total: function(response) {
return response.total; // total is returned in the "total" field of the response
}
}
两者均取自文档: http://docs.kendoui.com/api/framework/datasource#configuration-schema.total
以下是一个有效的例子:http://jsfiddle.net/lhoeppner/y6KdK/