PDA

View Full Version : How to get the value of a cell?



george.wei
31 Aug 2007, 2:02 AM
Hi! All,

If a column is not bound to a field of grid's data source, can I retrieve the value of a cell belongs to this column?

For example:


var colModel=new Ext.grid.ColumnModel([
{header:"Selected",width:40,
editor: new Ed(new fm.Checkbox())},
{id:"id",header:"ID",width:20,sortable:true,locked:true,dataIndex:"id"},
{header:"Name",width:100,sortable:true,dataIndex:"product.name"}
]);

grid=new Ext.grid.EditorGrid("grid-example", {
ds:ds, //ds is an instance of Ext.data.Store
cm:colModel,
selModel: new Ext.grid.RowSelectionModel({singleSelect:true})}
);


How to know which records are selected? Thanks for any clues.

Regards,
George

Animal
31 Aug 2007, 2:09 AM
http://extjs.com/deploy/ext-1.1.1/docs/output/Ext.grid.RowSelectionModel.html#getSelected

george.wei
31 Aug 2007, 6:24 PM
http://extjs.com/deploy/ext-1.1.1/docs/output/Ext.grid.RowSelectionModel.html#getSelected

Ooh...
Thanks for your reply. But actually, I mean how do I know which records are tagged as selected/checked according to my example? The first column uses Checkbox editor, but it doesn't bind to any field of grid's underlying data store.

Animal
31 Aug 2007, 11:54 PM
That is how you know which records are selected. But you want to use checkboxes for selection?

A Grid cell is always bound to a Record Field. How else is the value from that cell going to be stored? It is stored in that row's Record.

That will be using field 0 from the record as its underlying data. You will have to add a boolean Field to your Record to hold the value.

fay
1 Sep 2007, 3:23 AM
Although this is not for an Editor grid, I needed something similar so this might help you: http://extjs.com/forum/showthread.php?p=20549#post20549. As Animal says it needs to be bound to a field, in my example, this is basically a "calculated" field not in the underlying data.

george.wei
1 Sep 2007, 6:09 AM
OK, thans you two. I'll try to add an extra field.