PDA

View Full Version : get row data when the row is expanded



ejmelious
27 Nov 2007, 1:53 PM
Hi all,

I am attempting to get the row data when the row is expanded...seems simple enough, I just am not familiar with EXt enough to know how.

I am using the plugin rowExpander. Basically, when a row is expanded I am going to make an ajax call that will change a value in the database from N to Y. All I need to do is pass the columnId I have set to my soap request and the rest is already done.

This is where I want to get the row data, but don't know how to...



expandRow : function(row){
if(typeof row == 'number')
{
row = this.grid.view.getRow(row);
}
var record = this.grid.store.getAt(row.rowIndex);
var body = Ext.DomQuery.selectNode('tr:nth(2) div.x-grid3-row-body', row);
if(this.beforeExpand(record, body, row.rowIndex))
{
this.state[record.id] = true;
Ext.fly(row).replaceClass('x-grid3-row-collapsed', 'x-grid3-row-expanded');
this.fireEvent('expand', this, record, body, row.rowIndex);
}


I have tried a variety of things such as trying to get the cell and columnId, but nothing seems to be working.

Further information:

Here is my grid setup:



var colModel = new Ext.grid.ColumnModel([
sm,
expander,
{header: "From", width: 170, sortable: true, locked:false, dataIndex: 'fromName'},
{header: "Subject", width: 310, sortable: true, locked:false, dataIndex: 'subjectText'},
{header: "Date Received", width: 160, sortable: true, dataIndex: 'dateReceived'},
{header: "Reference #", width: 160, sortable:true, dataIndex: 'reference'},
{id:'id', header: "id", sortable: true, locked:false, hidden:true, dataIndex: 'id'}
]);





Any help is appreciated!

devnull
27 Nov 2007, 2:59 PM
expandRow : function(row){
if(typeof row == 'number')
{
row = this.grid.view.getRow(row);
}
var record = this.grid.store.getAt(row.rowIndex);
//'record' is the data.record from your grid's store for that row
var id = record.data.id;
//do something with 'id' here...
var body = Ext.DomQuery.selectNode('tr:nth(2) div.x-grid3-row-body', row);
if(this.beforeExpand(record, body, row.rowIndex))
{
this.state[record.id] = true;
Ext.fly(row).replaceClass('x-grid3-row-collapsed', 'x-grid3-row-expanded');
this.fireEvent('expand', this, record, body, row.rowIndex);
}

If the record's id is in fact what you mean by 'columnId'; its not that clear what you want.