<div id="grid"></div>
<script type="text/javascript">
var data = [
{ product: "Web", control: "AutoComplete" },
{ product: "Web", control: "Calendar" },
{ product: "Web", control: "ComboBox" },
{ product: "Web", control: "DatePicker" },
{ product: "Web", control: "DateTimePicker" },
{ product: "DataViz", control: "Chart" },
{ product: "DataViz", control: "LinearGauge" },
{ product: "DataViz", control: "RadialGauge" }
];
var grid = $("#grid").kendoGrid({
dataSource: data,
columns: [
{
field: "product",
title: "Product",
sortable: true
},
{
field: "control",
title: "Control"
}
],
selectable: "row",
sortable: true,
pageable: {
pageSize: 5
}
}).data("kendoGrid");
// Save the reference to the original sort function.
grid.dataSource.originalSort = grid.dataSource.sort;
// Replace the original sort function.
grid.dataSource.sort = function() {
// If a column is about to be sorted, then raise a new "sorting" event.
if (arguments.length > 0) {
this.trigger("sorting", arguments);
}
// Call the original sort function.
var result = grid.dataSource.originalSort.apply(this, arguments);
return result;
}
// Save the reference to the original page function.
grid.dataSource.originalPage = grid.dataSource.page;
// Replace the original page function.
grid.dataSource.page = function() {
// If the grid is about to be paged, then raise a new "paging" event.
if (arguments.length > 0) {
this.trigger("paging", arguments);
}
// Call the original sort function.
var result = grid.dataSource.originalPage.apply(this, arguments);
return result;
}
// Bind to the dataSource paging event.
$("#grid").data("kendoGrid").dataSource.bind("paging", function() {
if ($("#grid .k-state-selected").length > 0) {
//这里是分页事件 可以填写你需要的东西。保存当前页面数据之类的
if (console !== undefined) {
console.log("About to page and a row or cell is selected");
}
}
});
// Bind to the new dataSource sorting event.
$("#grid").data("kendoGrid").dataSource.bind("sorting", function() {
if ($("#grid .k-state-selected").length > 0) {
if (console !== undefined) {
console.log("About to sort and a row or cell is selected");
}
}
});
</script>
参考网页 http://down.51cto.com/data/952721