EasyUI Forum
May 17, 2024, 09:06:53 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: Don't clean checkedRows array when call loadData in datagrid  (Read 5952 times)
omhardb
Newbie
*
Posts: 11


View Profile Email
« on: January 15, 2015, 02:36:45 PM »

Hi!

I realize that the checkedRows collection in datagrid doesn't clean in the loadData method. In my case, I have a datagrid that use the checkbox to decide which rows must be deleted on the datagrid. In the first time, I check one of this row, then I create a new array without the checked row and use the loadData to set the new data. After that, I use the getChecked method to retrieve the checkedRows and I realize that the row who must be deleted it doesn't. That can be possible, because the datagrid have a new data and the data that I get from getChecked method is old.

Also, I realize that this issue happens because I set the idField in the data-options of the datagrid. If you see this function, in the jeasyui library, that is called when I use 'getChecked' method:

Code:
function _642(_643){
var _644=$.data(_643,"datagrid");
var opts=_644.options;
if(opts.idField){
return _644.checkedRows;
}else{
var rows=[];
opts.finder.getTr(_643,"","checked",2).each(function(){
rows.push(opts.finder.getRow(_643,$(this)));
});

If the 'idField' is seted then the function return the checkedRows collection, but this collection never is cleaned in the loadData method. So, if the 'data' would be changed then the checkedRows collection could keep old 'data'.

Maybe, is better that the checkedRows collection always be cleaned when the 'loadData' method will be called.

Regards,
Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 on: January 15, 2015, 03:44:43 PM »

If you set the 'idField', the checked rows will be stored all over your operations. When you go to next page and back to the previous page, the checked rows still exist and you can get all them again. You have to call 'clearChecked' method to clear these rows manually. If you wish for only storing the checked rows in current page, please prevent from setting the 'idField' property.
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!