PDA

View Full Version : show a gird row selected depending upon coditions



akshar_jamgaonkar
20 Sep 2012, 10:59 PM
Hello All,

I have a grid panel with

selModel : Ext.create('Ext.selection.RowModel', {
mode : 'SINGLE'
})


this grid panel is inside a formpanel, what i want is when it loads i show a specific row as selected. With every column of gridpanel associated with Renderer.


I have tried many things like

me.gridPanel.getSelectionModel().select(me.store.findRecord('id',1) )

me.gridPanel.getSelectionModel().select(me.store.findRecord('id',1) .data)


but iam unable to do this.


Kindly let me know what mistake iam i doing...



Thanks in advance.

scottmartin
22 Sep 2012, 2:53 PM
Select is looking for an index, not a record return by findRecord

Try the following:



Ext.create('Ext.data.Store', {
storeId : 'simpsonsStore',
fields : ['name', 'email', 'change'],
data : {'items' : [
{ 'name' : 'Lisa', 'email' : 'lisa@simpsons.com', 'change' : 100 },
{ 'name' : 'Bart', 'email' : 'bart@simpsons.com', 'change' : -20 },
{ 'name' : 'Homer', 'email' : 'home@simpsons.com', 'change' : 23 },
{ 'name' : 'Marge', 'email' : 'marge@simpsons.com', 'change' : -11 }
]},
proxy : {
type : 'memory',
reader : {
type : 'json',
root : 'items'
}
}
});

var grid = Ext.create('Ext.grid.Panel', {
title : 'Simpsons',
store : Ext.data.StoreManager.lookup('simpsonsStore'),
columns : [
{ header : 'Name', dataIndex : 'name' },
{ header : 'Email', dataIndex : 'email', flex : 1 },
{ header : 'Change', dataIndex : 'change' }
],
height : 200,
width : 400,
renderTo : Ext.getBody()
});

var index = grid.store.find('name','Bart');
grid.getSelectionModel().select(index);
‚Äč

Scott.