EasyUI Forum

General Category => Bug Report => Topic started by: java on August 04, 2012, 07:56:46 PM



Title: Datagrid can't display pageNumber where it's greater than 2.
Post by: java on August 04, 2012, 07:56:46 PM
For example:

Step1 : Download jquery-easyui-1.3.zip and zip to F:\jquery-easyui-1.3.
Step2 : Open F:\jquery-easyui-1.3\demo\datagrid.html in notepad and edit it as below( red lines is new added):


   $(function(){
         $('#test').datagrid({
            title:'My DataGrid',
            iconCls:'icon-save',
            width:700,
            height:350,
            nowrap: true,
            autoRowHeight: false,
            striped: true,
            collapsible:true,
            url:'datagrid_data.json',
            sortName: 'code',
            sortOrder: 'desc',
            remoteSort: false,
            idField:'code',
            pageNumber:3,
            pageSize:20,
            frozenColumns:[[
                   {field:'ck',checkbox:true},
                   {title:'Code',field:'code',width:80,sortable:true}
            ]],
              .........................


Step3 : Open F:\jquery-easyui-1.3\demo\datagrid.html in IE9.

I find pageSize is OK, but pageNumber is ineffective.

Please fix it as soon as possible...........


Title: Re: Datagrid can't display pageNumber where it's greater than 2.
Post by: stworthy on August 05, 2012, 01:10:13 AM
Override the datagrid loader to fix this bug:
Code:
$.extend($.fn.datagrid.defaults, {
loader: function(param, success, error){
var opts = $(this).data('datagrid').options;
var pager = $(this).datagrid('getPager');
if (pager.length && pager.pagination('options').total == 1){
pager.pagination('refresh',{
pageNumber:opts.pageNumber,
total: opts.pageNumber*opts.pageSize
});
}
if (!opts.url) return false;
$.ajax({
type: opts.method,
url: opts.url,
data: param,
dataType: 'json',
success: function(data){
success(data);
},
error: function(){
error.apply(this, arguments);
}
});
}
})

Another way to fix this bug is to download the pagination plugin from http://www.jeasyui.com/easyui/plugins/jquery.pagination.js.


Title: Re: Datagrid can't display pageNumber where it's greater than 2.
Post by: java on August 05, 2012, 08:26:00 PM
Thank you. 

 It's ok that override the datagrid loader by first way,

But download http://www.jeasyui.com/easyui/plugins/jquery.pagination.js to overwrite old file is no effective.