PDA

View Full Version : How to get unselected rows on a grid ?



Elfayer
20 Aug 2012, 12:23 AM
Hi,

I have a grid :
38077

I can get the seleced rows with :



Ext.each(userGrid.getSelectionModel().getSelection(), function (item, index, array) {
alert(item.get('usr_firstname') + ' ' + item.get('usr_lastname'));
});


But I want the unselected rows, and didn't find a method to do it.

evant
20 Aug 2012, 12:30 AM
Ext.define('Thing', {
extend: 'Ext.data.Model',
fields: ['name']
});

Ext.require('*');

Ext.onReady(function(){

var data = [],
i = 1;

for (; i < 11; ++i) {
data.push({
name: 'Name ' + i
});
}

var store = new Ext.data.Store({
model: Thing,
data: data
});

var grid = new Ext.grid.Panel({
tbar: [{
text: 'Go',
handler: function(){
var selections = grid.getSelectionModel().getSelection(),
all = store.getRange(),
diff = Ext.Array.difference(all, selections);

Ext.Array.forEach(diff, function(rec){
console.log(rec.get('name'));
});


}
}],
multiSelect: true,
renderTo: document.body,
width: 400,
height: 400,
columns: [{
dataIndex: 'name',
text: 'Name'
}],
store: store
});

});

Elfayer
20 Aug 2012, 2:17 AM
Thanks that's working.

The thing I'm trying to do is : when I click on a Company (in the companies tabpanel), if a user is in that company and isn't already selected, I select him. But I can't select anybody...

I've tried some things but that even doesn't work.


'#gridCompanies': {
select: function (item, record) {
var me = this;
var userGrid = Ext.ComponentQuery.query('#gridUsers')[0];

var selections = userGrid.getSelectionModel().getSelection();
var all = me.getUsersStore().getRange();
var diff = Ext.Array.difference(all, selections);

Ext.each(diff, function (item) {
if (item.data.usr_company == record.data.cmp_label) {
alert(item.get('usr_firstname'));
// I get the good users here
// >>> didn't find something functional
}
})
}
}