EasyUI Forum
March 28, 2024, 01:01:09 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Refresh datagrid pagination doesn't refresh datagrid options  (Read 6715 times)
rickysang
Newbie
*
Posts: 1


View Profile
« on: December 22, 2016, 12:59:50 AM »

I want to implement a functionality to change page size of datagrid using JavaScript code. I refreshed pagination pageSize option with new value, no requests fired. Then I called datagrid reload method, a request is fired with old parameter.

For quick fix, I have to change datagrid pageSize option manually before reload data from service(implement datagrid onBeforeLoad event). I'm not sure if this is an easyui defect. Any help is appreciated.

This is how I got it working. Comment out onBeforeLoad event, it fails to work properly.
Code:
$('#table').datagrid({
    url: 'datagrid.json',
    pagination: true,
    columns: [[
        { field: 'id', title: 'Id', width: 100 }
    ]],
    onBeforeLoad: function (param) {
        var pageSize = $(this).datagrid('getPager').pagination('options').pageSize;
        if (param.rows !== pageSize) {
            param.rows = pageSize;
            $(this).datagrid('options').pageSize = pageSize;
        }

        return param;
    }
});

setTimeout(function () {
    $('#table').datagrid('getPager').pagination('refresh', { pageSize: 20 });

    setTimeout(function () {
        $('#table').datagrid('reload');
    }, 30);
}, 3000);
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #1 on: December 22, 2016, 05:17:20 PM »

You just need to construct the datagrid with the new 'pageSize' property.
Code:
$('#table').datagrid({
  pageSize: 20
});
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!