I'm using version 3.3 of easyui for a CMS. It's a SSH structured project.
I got a datagrid defined like this:
<table id="dg" class="easyui-datagrid" pagination="true" pageSize=20
loadMsg="Loading!"
data-options="autoRowHeight:true,fit:true,rownumbers:true,remoteSort: true,singleSelect:true,url:'../struts/Application_queryApplications',toolbar:'#tb'">
<thead>
<tr>
<th data-options="field:'applyId',width:80,hidden:true">ID</th>
<th data-options="field:'email',width:80">email</th>
</tr>
</thead>
</table>
And there is a toolbar '#tb' to filter data with conditions.
anyway the filter function is wrote like this.
var con = $('#confirm').combobox('getValue');
var fol = $('#follow').combobox('getValue');
// alert(con + ' '+fol);
$('#dg').datagrid('load', {confirmed : con, follow : fol});
I got test data records in my db so there are always records showed in the datagrid when first loading. It all goes well, so that means I did get the datagrid well defined. However something very strange happened when I was testing the filter function, the datagrid won't refresh to a empty one when I got empty json rows from response. It remains the same before filtering instead. the response goes like this:
{'success':true,'message':'','total':0,'rows':[]}
I did a test from server side, to change the json response to
{'success':true,'message':'','total':0,'rows':[]}
in the first loading. The datagrid did load as a empty one. But once it was loaded with data. I can never get it to empty with this function:
$('#dg').datagrid('load', {confirmed : con, follow : fol});
This
$('#dg').datagrid('loadData', {'success':true,'message':'','total':0,'rows':[]});
can always empty the datagrid, but that's not the solution I'm looking for. In this case, I need to load data from server side by query it from db.
So I'm thinking the 'load' function of datagrid didn't remove the old rows before setting new rows. If there is a removal, It certainly didn't work in the empty row case. I could have look in the source code to find out why, only I'm pretty new in JS and the source code wasn't that readable. I'm there is no commont at all and all the functions are named with number and all. So here I'm. Looking for help!
Any suggestion will be appreciated.