PDA

View Full Version : [1.1.1] Record info after operation over records isn't refreshing



wolverine4277
2 Oct 2007, 5:16 AM
This problem has already discussed but still is there...

http://extjs.com/forum/showthread.php?t=12641&highlight=bug+refresh
http://extjs.com/forum/showthread.php?t=12383&highlight=onRefresh+function%28%29%7B

ext-1.1.1/source/widgets/grid/RowSelectionModel.js


onRefresh : function(){
var ds = this.grid.dataSource, i, v = this.grid.view;
var s = this.selections;
s.each(function(r){
if((i = ds.indexOfId(r.id)) != -1){
v.onRowSelect(i);
}else{
s.remove(r);
}
});
}

if i add the lines that animal says then works fine.

jsakalos
2 Oct 2007, 12:24 PM
I'm notifying Jack on this.

jack.slocum
2 Oct 2007, 10:11 PM
It works fine for me. Do you mean it loses selections after paging or ?

wolverine4277
3 Oct 2007, 3:24 AM
the situation is this:

one paging grid linked to one table with one field that determines if one operation (edit or delete) can be performed based in his value (true -> can performed, false -> can't performed)
one button in the toolbar of the grid that download the selected records on the grid and change the value of the field from false to true (that is, the operations edit and delete can't be performed on that record)

when i select records and download them the load method of the store linked with the grid is called (e.g. this._dataStore.load({params: {start: 0, limit: this._recordsPerPage}})
After that i try to edit/delete one of the records marked as false and the check for that value fails because the value returned is true and not false.
I check with Firebug and the values in the store is ok, but the records returned by the method getSelections() from grid are the ones before the last operation was perfomed


_operationCanBePerformed: function() {

var records = this._grid.getSelections();
var invalidRecordsForOperation = 0;

for(var i = 0; i < records.length; i++) {
if (!records[i].get('mark')) {
invalidRecordsForOperation++;
}
}

return (invalidRecordsForOperation > 0);
}

The same happens if i press the refresh button of the toolbar of the grid.
Excuse me if my English is bad but isn't my primary language.

jsakalos
3 Oct 2007, 8:50 AM
If this._grid in the posed code is Ext.grid.Grid object then it has no method getSelections, which is the method of the RowSelectionModel.

You can get selections this way:




var records = this._grid.getSelectionModel().getSelections(); //returns array of selected records

This will work only if you use RowSelectionModel for the grid.

wolverine4277
3 Oct 2007, 11:32 AM
Hi jsakalos, _grid is an instance of Ext.grid.Grid.
In the file ext-1.1.1/source/widgets/grid/Grid.js i found the code:


getSelections : function(){
return this.selModel.getSelections();
}

anyway, if i use _grid.getSelectionModel().getSelections(); the result is the same... and have sense because the code is the same... :(

jsakalos
3 Oct 2007, 12:35 PM
Oh, yes.

I was looking in doc and it's not there. Marked private in source.

Could you post complete showcase I could drop in examples showing the issue? Or a public link?

wolverine4277
3 Oct 2007, 3:05 PM
Ok, i will put a public link as fast as i can.