EasyUI Forum
May 03, 2024, 07:43:09 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [FIXED] how can i clear the rows of datagrid  (Read 22617 times)
wade.zhu
Newbie
*
Posts: 27


View Profile
« on: August 12, 2014, 02:20:10 AM »

i have a datagrid and a search form, when submit search form, i want to clear the previous results first, then load new data from remote.
i didn't find 'clear', 'reset' or something else in the docs
i try to use loadData method to load empty data instead, like this:

Code:

$('#dtgResult').datagrid('loadData', []);// supposed to clear previous results
$('#dtgResult').datagrid('load', serialize($('#frmSearch'));// fetch new results from remote


i found loadData method will trigger loader to load data from remote if opt.url is not empty
it is not supposed to load remote data after loadData from local.

is that a bug?
or is there anyway to meet my requirement?
« Last Edit: August 12, 2014, 08:21:59 PM by wade.zhu » Logged
hjzhbb7758
Jr. Member
**
Posts: 84


View Profile Email
« Reply #1 on: August 12, 2014, 02:55:59 AM »

hei,gay。where‘re you from /?
Logged
aswzen
Sr. Member
****
Posts: 287


Indonesian

aswzen
View Profile WWW Email
« Reply #2 on: August 12, 2014, 03:16:28 AM »

try run this script..

Code:
$('#your_table_id').datagrid('loadData', {"total":0,"rows":[]});
Logged

Regards,
Sigit

- Indonesian jEasyUI Facebook page : https://www.facebook.com/groups/jeasyuiid/
wade.zhu
Newbie
*
Posts: 27


View Profile
« Reply #3 on: August 12, 2014, 07:38:15 PM »

i found a bug of datagrid when no data filled, see the code bellow
Code:
<table class="easyui-datagrid" title="Basic DataGrid" style="width:700px;height:250px"
data-options="pagination:true,pageSize:10">
<thead>
<tr>
<th data-options="field:'itemid',width:80">Item ID</th>
<th data-options="field:'productid',width:100">Product</th>
<th data-options="field:'listprice',width:80,align:'right'">List Price</th>
<th data-options="field:'unitcost',width:80,align:'right'">Unit Cost</th>
<th data-options="field:'attr1',width:250">Attribute</th>
<th data-options="field:'status',width:60,align:'center'">Status</th>
</tr>
</thead>
</table>
url property is undefined, the pager shows incorrectly,that is why loadData will trigger loader to load data
_5d7(_60f); at line 8668 executed and loader will be called when loadData [].

Code:
var _614=$(_60f).datagrid("getPager");
if(_614.length){
var _615=_614.pagination("options");
if(_615.total!=data.total){
_614.pagination("refresh",{total:data.total});
if(opts.pageNumber!=_615.pageNumber){
opts.pageNumber=_615.pageNumber;
_5d7(_60f);//line 8668
}
}
}
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #4 on: August 12, 2014, 07:55:41 PM »

By default the 'pageNumber' property is set to 1, you can set it to 0 if the 'url' property is not defined.
Code:
$('#dg').datagrid({
  pageNumber:0
});
Logged
wade.zhu
Newbie
*
Posts: 27


View Profile
« Reply #5 on: August 12, 2014, 08:21:27 PM »

yeah, it works upon lastest jquery.easyui.patch.js.
pageNumber will be reset to 1 when load remote.
thanks.
Code:
$('#dtgResult').datagrid('options').pageNumber = 0; // reset pageNumber for bug-fixing loadData
$('#dtgResult').datagrid('loadData', []);// supposed to clear previous results
$('#dtgResult').datagrid('load', serialize($('#frmSearch'));// fetch new results from remote

i suggest adding 'clear' method or something like this in next version. Smiley
Logged
zhcnlei
Newbie
*
Posts: 14


View Profile Email
« Reply #6 on: September 03, 2014, 01:25:35 AM »

this problem does exist

[page] parameter, second post is 0

after using the patch, [page] parameter is 1

however, rows.length == 0, it will still be post twice
« Last Edit: September 03, 2014, 01:28:05 AM by zhcnlei » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #7 on: September 03, 2014, 02:06:53 AM »

Please try to download the patch from http://www.jeasyui.com/download/downloads/jquery-easyui-1.4-patch.zip.
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!