PDA

View Full Version : Row selection?



loveforvdubs
5 Oct 2010, 1:06 PM
Sorry if this is a very newb question but I am pretty new to ExtJs and after searching everywhere have still come up empty for an answer to this question. I want to be able to grab a row of a grid using the row index and then use the data in the cells for some logic. What is the best way to access the data in a grid?

tfcoding
5 Oct 2010, 1:30 PM
Hmm ok, in effect you provide not much infos where your progress stucks, i can only giv the hint that you can use the selection model.

Example: with this code i show dynamicly data from the grid on a xtemplate



xtype: 'grid',
store: 'store',
autoRef: 'grid',
itemId:'artGrid',
sm: new Ext.grid.RowSelectionModel({
singleSelect:true,
listeners:{
rowselect:{
fn:function (sm,index,record){
dataTemplate.update(record.data);

}
}
}
}),....


hope that helps

Nightwish
5 Oct 2010, 1:30 PM
Many ways to do it depending on the original event coming from the grid - click, select, doubleclick, etc. You can always add a listener for one of these - the listeners are always called with the record and/or the record's index in the grid store.

Of course, you can always use the store's getAt() method to get a specific record:



Ext.StoreMgr.get('MyStoreID').getAt(recordIndex);

loveforvdubs
6 Oct 2010, 4:30 AM
.getAt() did the trick. Thanks for your help