How do I assign rows number in total property in kendo grid? I used json to fill the data:
if ($result = mysqli_query($con,$sql)) {
while($obj = mysqli_fetch_object($result)) {
$arr[] = $obj;
}
}
echo "{\"list\":" .json_encode($arr). "}";
But paging does not work with total = total or function ! I don't know where is my grid problem!!
$(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 ....
From what I see in your code, total
function should be:
total: function (response) {
return response.list.length;
}
What you are returning from PHP is a JSON object that includes an array
in a field called list
and this is a JSON object (once in KendoUI total
). So, the reference to the array is response.list
and the length response.list.length
.