kendoui grid控件 page分页事件


<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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM