View Full Version : its posible to "cellEdit" a column with renderer set ?

26 Feb 2012, 8:24 AM
i have 2 stores,
as an example
store1 has all access to the system (just like an array of strings )
store2 has all access that a user has (a subset of store1)
to the present this to the admin i display the store1 in a grid and add extra column that has a renderer function instead of setting a dataIndex.
renderer will ask, for each record, if exists in store2, if so will display "yes" (or "no").
this works fine.

now i want to edit that extra column with cellEditing grid plugin.
looking at the source code saw cellEditing depends on a dataIndex is set, cant work with a column that depends on a renderer function.

is theres a way to get this working with cellEditing ? or anyone know a user extension that allow to do that (been lookin in user extension forum but cant find anything? i dont want to create a new version cellEditing to work with this kind of cells D:

the solution im thinking is to build a cellEditor that instead of working with the current cell dataIndex, works against a setter and getter functions defined in the column.

currently seems like cellEditing works the same way but uses the set and get directly from a record using the dataIndex.

// this is a grid column
{ header: 'normal field',
dataIndex : 'someStoreFieldName'
editor :
{ ... some editor ....

and when cellEditing wants to "load" the value, uses the store.get(dataIndex)
and after editing does a store.set(dataIndex, value)

using renderer function theres no dataIndex so theres no way to set or get the value. so a new version of cellEditing plugin should, instead of asuming a dataIndex and use its get / set value, expect the field has a set/get function.

// this is a grid column
{ header: 'field with renderer',
renderer : function() {... do w/e you want to display this value ... }
getter : function() { ... give to editor the value of this field .... }
setter : function(value){ ... excute some code to save the value .... }
editor :
{ ... some editor ....

i think its a small change to default cellEditor plugin, just instead of using dataIndex getter / setter use the setter/getter defined in the field, IF theres no dataIndex

so anyone know a user extension that allow to do that ? or theres a way to this ? i dont want to create a new version cellEditing D:

26 Feb 2012, 4:20 PM
I can think of a few ways you might do this. My first instinct is to go for the path of least resistance: give the plugin what it wants, a field in your data. Add a new field with a convert function to derive a suitable editable value. Then hook into the events to propagate the changes when editing completes.

Even if the convert function relies on data in another store it should be no worse than writing the renderer.

26 Feb 2012, 5:22 PM
yeah were thinking that. the problem is a have a script that builds up all the extjs models given the database schema but i guess the easiest way to go is just to build another store/model D: