EasyUI Forum
April 28, 2024, 03:39:56 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
  Home Help Search Login Register  
  Show Posts
Pages: [1]
1  General Category / Bug Report / Refresh datagrid pagination doesn't refresh datagrid options 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);
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!