PDA

View Full Version : Grid cell editor that filters value



JoelCool
4 Jun 2012, 10:19 AM
I have a grid where the store value looks like "8:0.36" (without the quotes). The user just sees the "8" as I use a renderer to remove the ":0.36" part. Now I'd like to allow editing but when editing starts it shows the entire "8:0.36" where I only want them to see the "8". Once they type in something like "4" I need it to re-assemble back to "4:0.36".

I've searched for custom cell editors without any luck. I've also tried modifying the e.value in the 'beforeedit' event.

What is the simplest way I could achieve this, or is it even possible?

Tx!

mitchellsimoens
7 Jun 2012, 1:28 PM
Looks like the editor get the value from the record


field.setValue(me.context.record.get(column.dataIndex));

JoelCool
7 Jun 2012, 2:33 PM
Yep, but in my case the value is like '
8:0.36' and I just want the editor to edit the '8' part. So what I did was added some custom code to the ext-all.js file for the startEdit() function of 'Ext.grid.plugin.CellEditing' to store off the '0:36' part and leave just the '8' and then in the 'onEditComplete()' function I re-assemble the data back with the new value.

It works, I just don't like going into the code and making customizations like that. I'm sure it could be sub-classed if I knew enough to do something like that. Maybe later.... /:)