The 'autoPageSize' method can be extended as:
$.extend($.fn.datagrid.methods,{
autoPageSize:function(jq){
return jq.each(function(){
var that = $(this);
that.datagrid('options').onResize = function(){
setPageSize();
};
setPageSize();
function setPageSize(){
var body2 = that.datagrid('getPanel').find('div.datagrid-view2 div.datagrid-body');
var pageSize = parseInt(body2.height()/25);
if (pageSize){
var opts = that.datagrid('options');
opts.pageSize = pageSize;
opts.pageList = [10,20,30,pageSize].sort(function(a,b){return a-b});
that.datagrid('getPager').pagination({
pageSize: opts.pageSize,
pageList: opts.pageList
}).pagination('select',opts.pageNumber);
}
}
});
}
});
To enable this feature, call 'autoPageSize' method on datagrid.
$('#dg').datagrid('autoPageSize');