PDA

View Full Version : gridpanel selectionmodel not catching null values.



mond
26 Nov 2010, 7:53 PM
hi guys, i have a problem with gridpanel

i am trying to automatic remove the selected row when the grid is rendered.
unfortunately im not successfull to do it.

here is my code.

var grid2 = Ext.getCmp('buildGrid');
var record= grid2.getSelectionModel().getSelected();
var m = grid2.getSelectionModel().getSelections();
var bcode = m[0].get('ACCTNO');

if(bcode == null){
_store3.remove(record);
}else{
return false;
}
return true;

Condor
26 Nov 2010, 11:55 PM
1. Why do you need getSelections()[0]? It's the same as getSelected().
2. What doesn't work?

mond
29 Nov 2010, 4:32 PM
ok. my gridpanel is returning null values and i want to remove that row when the grid is loaded. but it doesnt work. it might be to validate all the columns i have bcode,account no and name.

Condor
29 Nov 2010, 11:29 PM
But you are removing the selected record, not records with null values.


grid2.getStore().on('load', function(store){
store.each(function(rec){
if(!rec.get('ACCTNO')){
store.remove(rec);
}
});
});

mond
29 Nov 2010, 11:57 PM
hi condor, i too way confuse because im inside in a function here is the complete code:

function matches(_store3){
var grid2 = Ext.getCmp('buildGrid');
var record= grid2.getSelectionModel().getSelected();
var m = grid2.getSelectionModel().getSelections();
var bcode = m[0].get('ACCTNO');

if(bcode == null){
_store3.remove(record);
}
return true;
}

Condor
30 Nov 2010, 12:07 AM
1. _store3 === grid2.getStore()?

2. When is this function called?

mond
30 Nov 2010, 12:12 AM
_store3 is variable to be passed in grid store.

in grid listeners properties

listeners : {
'viewready' : function(g){
g.getSelectionModel().selectRow(0);
matches(_store3);
}
},

Condor
30 Nov 2010, 12:23 AM
Yes, but your are trying to remove a record from _store3 that you got from grid2.getStore(). This will only work if _store3 === grid2.getStore().