PDA

View Full Version : Getting all selected data from CheckboxSelectionModel



LeonM
10 Jun 2010, 8:06 AM
Hi all,

I'm kinda new to EXT-JS, and I have hit a problem. I have searched the forum, and could not find an answer, although I think my question is pretty noobish

I've got a GroupingStore, that uses a JsonReader, it holds information about vehicles from our database. The vehicles are displayed using a GridPanel with CheckboxSelectionModel.

One of the fields in the store is called "CarID", I want to get the CarID value of all selected rows in the grid. I want to do this in the rowSelect handler of the CheckboxSelectionModel

I know that

thisGrid.getSelected().get('CarID');
works just fine on a single row, but I have absolutely no clue how to do this on multiple selected rows.




records = thisGrid.getSelections();
Returns me an object, but using records.getAt(#) does not seem to work.

I have also tried using the "classic" JS method: records[i].data.CarID, but apparently this is not the way to do this since firebug complains about it (OK, I have to admit I'm kinda new to JS as wel, I used to be a C programmer...)

I need all the CarID's in an array, so I can make a JSON string of it, to pass to my PHP function that selects all corresponding drivers from my database.

Can anyone help?

pavanextjs
10 Jun 2010, 11:51 AM
Try this, to create an array.


var records = thisGrid.getSelections(),
idArray = [];

Ext.each(records, function(record, idx, arr){
idArray.push(record.data.CarID);
});

console.log(Ext.encode(idArray);

LeonM
10 Jun 2010, 11:38 PM
Try this, to create an array.


var records = thisGrid.getSelections(),
idArray = [];

Ext.each(records, function(record, idx, arr){
idArray.push(record.data.CarID);
});

console.log(Ext.encode(idArray);


Thanks pavanextjs, that worked just fine!