如何在剑道网格中分配总属性中的行数?我使用json来填充数据:
if ($result = mysqli_query($con,$sql)) {
while($obj = mysqli_fetch_object($result)) {
$arr[] = $obj;
}
}
echo "{'"list'":" .json_encode($arr). "}";
但是分页不能使用total = total或function !我不知道我的网格问题在哪里!!
$(document).ready(function () {
var record = 0;
var grid = $("#grid").kendoGrid({
dataSource: {
transport: {
read: {
url: "<?php echo $path?>/contractors.php?m=read&f=subcat",
dataType: "json"
}
},
schema: {
data: "list",
model: {
id: "id",
fields: {
company: { type: "string" },
firstname: { type: "string" },
lastname: { type: "string" }
}
},
total: function (response) {
return $(response.data).length;
}
},
pageSize: 20,
serverPaging: true
},
pageable: true ....
从我在你的代码中看到,total
函数应该是:
total: function (response) {
return response.list.length;
}
你从PHP返回的是一个JSON对象,其中包括一个array
在一个名为list
的字段中,这是一个JSON对象(一次在KendoUI total
)。因此,对数组的引用是response.list
,长度是response.list.length
。