Hi,
I recently implemented serverPaging on my grid, however I noticed that when I sort it only sorts the data on that page and not the data as a whole. I have added serverSorting: true, but this now stops any kind of sorting. Can anyone assist on how to get this working or point me in the direction on some examples in PHP? That would be much appreciated.
$(document).ready(function() {
$("#grid").kendoGrid({
dataSource: {
transport: {
read: {
dataType: "json",
url: "<?php echo BASE_PATH; ?>admin/account_data"
}
},
schema: {
total: "total",
data: "result",
model: {
fields: {
id: {type: "number"},
name: {type: "string"},
company: {type: "string"},
email: {type: "email"}
}
}
},
serverPaging: true,
serverFiltering: true,
serverSorting: true,
pageSize: 25
},
scrollable: false,
sortable: true,
filterable: true,
selectable: "row",
detailTemplate: kendo.template($("#detailTemplate").html()),
detailInit: detailInit,
pageable: {refresh: true, },
columns: [
{field: "id", title: "ID", filterable: false},
{field: "name", title: "Name"},
{field: "company", title: "Company"},
{field: "email", title: "Email"}
],
editable: "inline"
});
// The PHP code getting the data
function account_data() {
//get current page from URL
$get = $_SERVER['REQUEST_URI'];
parse_str($get);
if (isset($page)) {
if ($page == 1) {
$start = 1;
} else {
$start = $skip + 1;
}
$limit = $page * $pageSize;
} else {
$start = 0;
$limit = 50;
}
$data= $admin->getData($start, $limit);
$countData = $admin->countData($start, $limit);
$data_arr['result'] = $data;
$data_arr['total'] = $countData ;
$this->set('accounts_data', $data_arr);
}
I recently implemented serverPaging on my grid, however I noticed that when I sort it only sorts the data on that page and not the data as a whole. I have added serverSorting: true, but this now stops any kind of sorting. Can anyone assist on how to get this working or point me in the direction on some examples in PHP? That would be much appreciated.
$(document).ready(function() {
$("#grid").kendoGrid({
dataSource: {
transport: {
read: {
dataType: "json",
url: "<?php echo BASE_PATH; ?>admin/account_data"
}
},
schema: {
total: "total",
data: "result",
model: {
fields: {
id: {type: "number"},
name: {type: "string"},
company: {type: "string"},
email: {type: "email"}
}
}
},
serverPaging: true,
serverFiltering: true,
serverSorting: true,
pageSize: 25
},
scrollable: false,
sortable: true,
filterable: true,
selectable: "row",
detailTemplate: kendo.template($("#detailTemplate").html()),
detailInit: detailInit,
pageable: {refresh: true, },
columns: [
{field: "id", title: "ID", filterable: false},
{field: "name", title: "Name"},
{field: "company", title: "Company"},
{field: "email", title: "Email"}
],
editable: "inline"
});
// The PHP code getting the data
function account_data() {
//get current page from URL
$get = $_SERVER['REQUEST_URI'];
parse_str($get);
if (isset($page)) {
if ($page == 1) {
$start = 1;
} else {
$start = $skip + 1;
}
$limit = $page * $pageSize;
} else {
$start = 0;
$limit = 50;
}
$data= $admin->getData($start, $limit);
$countData = $admin->countData($start, $limit);
$data_arr['result'] = $data;
$data_arr['total'] = $countData ;
$this->set('accounts_data', $data_arr);
}