EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: sloop on June 12, 2014, 07:29:47 AM



Title: datagrid filter - how to reload
Post by: sloop on June 12, 2014, 07:29:47 AM
I setup my first datagrid like the following:

Code:
  <table id="fishdg" title="DataGrid" style="width:700px;height:250px" data-options="
                singleSelect:true,
                url:'/get_fish.php'
            ">
        <thead>
            <tr>
                <th data-options="field:'id',width:80">ID</th>
                <th data-options="field:'model',width:100">Model</th>
            </tr>
        </thead>
    </table>
    <script type="text/javascript">
        $(function(){
            var dg = $('#fishdg').datagrid();
            dg.datagrid('enableFilter');
        });
    </script>

This works fine for loading data and client-side filtering.  But, I have added functionality for users to edit/delete rows following the example CRUD Applicaiton code.

when using datagrid-filter, I am unable to reload data from server using:

Code:
$('#dg').datagrid('reload');

Now, the above WILL work if I set remoteFilter to true.  But, I don't want to do filtering at the server side, I want to keep filtering local.



Title: Re: datagrid filter - how to reload
Post by: stworthy on June 12, 2014, 06:34:22 PM
Please try to download the newest 'datagrid-filter.js' file from http://jeasyui.com/extension/datagrid_filter.php


Title: Re: datagrid filter - how to reload
Post by: sloop on June 13, 2014, 05:22:39 AM
Please try to download the newest 'datagrid-filter.js' file from http://jeasyui.com/extension/datagrid_filter.php

That seems to have fixed it, thanks!


Title: Re: datagrid filter - how to reload
Post by: dnhoang on June 23, 2014, 09:21:50 PM
I can reload datagrid by button on datagrid toolbar, but I still can not reload by reload button of pagination toolbar. Can you help me?


Title: Re: datagrid filter - how to reload
Post by: hande89 on February 23, 2015, 09:22:09 AM
I have the same problem. I would like to move the pagination to server side. Datagrid loads fine, but when I change to next page, it's not sending any request.

Also the filter rules are sent to server even if remoteFilter = false.


Title: Re: datagrid filter - how to reload
Post by: hande89 on February 24, 2015, 04:56:21 AM
I have the same problem. I would like to move the pagination to server side. Datagrid loads fine, but when I change to next page, it's not sending any request.

http://www.jeasyui.com/forum/index.php?topic=3820.0
http://www.jeasyui.com/forum/index.php?topic=4303.0

These topics help to solve this issue. Another way is not to recreate the pagination component in myLoadFilter method of datagrid-filter.js (remove this code):

Code:
			if (opts.pagination){
var dg = $(this);
var pager = dg[name]('getPager');
pager.pagination({
onSelectPage:function(pageNum, pageSize){
                    opts.pageNumber = pageNum;
                    opts.pageSize = pageSize;
                    pager.pagination('refresh',{
                        pageNumber:pageNum,
                        pageSize:pageSize
                    });
                    //dg.datagrid('loadData', state.filterSource);
                    dg[name]('loadData', state.filterSource);
},
onBeforeRefresh:function(){
dg[name]('reload');
return false;
}
});
if (name == 'datagrid'){
var start = (opts.pageNumber-1)*parseInt(opts.pageSize);
var end = start + parseInt(opts.pageSize);
data.rows = data.rows.slice(start, end);
} else {
        var topRows = [];
        var childRows = [];
        $.map(data.rows, function(row){
        row._parentId ? childRows.push(row) : topRows.push(row);
        });
        data.total = topRows.length;
        var start = (opts.pageNumber-1)*parseInt(opts.pageSize); 
        var end = start + parseInt(opts.pageSize); 
data.rows = $.extend(true,[],topRows.slice(start, end).concat(childRows));
}
}