jQuery EasyUI DataGrid - Custom Pagination
The datagrid has a built-in pagination feature with great capabilities, and customizing it is quite simple. In this tutorial, we will create a datagrid and add some custom buttons to the pagination toolbar.
Create the DataGrid
Item ID
Product ID
List Price
Unit Cost
Attribute
Stauts
Remember to set the 'pagination' property to true so that the pagination toolbar is generated.
Customize the pagination toolbar
var pager = $('#tt').datagrid('getPager'); // get the pager of datagrid
pager.pagination({
showPageList:false,
buttons:[{
iconCls:'icon-search',
handler:function(){
alert('search');
}
},{
iconCls:'icon-add',
handler:function(){
alert('add');
}
},{
iconCls:'icon-edit',
handler:function(){
alert('edit');
}
}],
onBeforeRefresh:function(){
alert('before refresh');
return true;
}
});
As you can see, we first get the datagrid's pager object, then recreate the pagination. We hide the page list and add three new buttons.