EasyUI Forum

General Category => Bug Report => Topic started by: omhardb on January 15, 2015, 02:36:45 PM



Title: Don't clean checkedRows array when call loadData in datagrid
Post by: omhardb 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,


Title: Re: Don't clean checkedRows array when call loadData in datagrid
Post by: jarry 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.