PDA

View Full Version : EditorGrid - setCellEditable



TheRebelGriz
27 May 2007, 9:48 AM
All,

Using Ext Version: 1.0.1a

I have an EditorGrid with the following columns ['Attr_Type','Attr_Domain','Attr_Value']....
Columns Attr_Type and Attr_Domain defined as 'readonly: true' so the user cannot update them...

I also have an 'Add Row' button on the toolbar of the user to create new data rows...

However, the user cannot type in the values of Attr_Type & Attr_Domain bc/of the readonly:true property... I see that there is a isCellEditable, but I do not see a setCellEditable( row, col, [boolean] ) function.

Question:
Has anyone run into this type of need and/or know of a workaround based on the scenario presented above?

Any assistance is greatly appreciated!!

jsakalos
28 May 2007, 3:02 AM
All,

Using Ext Version: 1.0.1a

I have an EditorGrid with the following columns ['Attr_Type','Attr_Domain','Attr_Value']....
Columns Attr_Type and Attr_Domain defined as 'readonly: true' so the user cannot update them...

I also have an 'Add Row' button on the toolbar of the user to create new data rows...

However, the user cannot type in the values of Attr_Type & Attr_Domain bc/of the readonly:true property... I see that there is a isCellEditable, but I do not see a setCellEditable( row, col, [boolean] ) function.

Question:
Has anyone run into this type of need and/or know of a workaround based on the scenario presented above?

Any assistance is greatly appreciated!!

ColumnModel has setEditable method. If it's not enough you can override isCellEditable method.

Hi,

TheRebelGriz
28 May 2007, 5:36 AM
Thanks for suggesting the override...

I've given this a try by overriding the 'Ext.override(Ext.grid.ColumnModel, {...});' isCellEditable function... Now, I seem to run into a scope issue...

The reason being that I need access to the record data to check the value of the 'newRecord' column to determine if the cell is Editable or not...

Do you know of a way to grab a record if your scope is within the ColumnModel?

jsakalos
28 May 2007, 5:28 PM
Thanks for suggesting the override...

I've given this a try by overriding the 'Ext.override(Ext.grid.ColumnModel, {...});' isCellEditable function... Now, I seem to run into a scope issue...

The reason being that I need access to the record data to check the value of the 'newRecord' column to determine if the cell is Editable or not...

Do you know of a way to grab a record if your scope is within the ColumnModel?


The dirty solution would be to save store in the cm like this




var store = new ....
var cm = new ...
cm.store = store;



I guessed that there is grid property in cm and in the grid it is dataSource, but haven't found it at the first glance... Maybe if you look better...

Hi,

jack.slocum
28 May 2007, 6:32 PM
var cm = new Ext.grid.ColumnModel(...);

cm.isCellEditable = function(....){ // <-- one time override
// your stuff
};

TheRebelGriz
29 May 2007, 5:11 AM
Jack,

Thanks for the insight...

I keep forgetting that javascript is more free form than the language I primarily use...
And that you can easily overwrite / extend and object to include what you need...

For those interested in the functionality, the following is an exmaple usage based on Jack's suggestion... which turns out to be very simple...



cmAttrs.store = dsAttrs; // the columnModel needs a reference to the DataStore
cmAttrs.isCellEditable = function(colIndex, rowIndex) {
if ( this.store.getAt(rowIndex).get('attr_id') != '' )
{
console.log( 'Existing row, get edit rules from the ColumnModel...' );
return ( this.config[colIndex].editable
|| ( typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor )
) ? true : false;
} else
{
console.log( 'Editing a new record, except column 1...' );
return ( colIndex > 0 ) ? true : false;
}

Thanks again Jack for the insight, the light bulb just got a little brighter...