PDA

View Full Version : How to make a cell editable?



msuresh
7 Jan 2011, 4:26 AM
Hi,
I have set one of my column's editable property as false. I need to make it true on certain conditions.
I am able to check whether cell is editable or not by using "isCellEditable". However when I use setEditable(columnNumber,boolean), the entire column becomes editable.

How can I make a particular cell editable, any function like setCellEditable(rowNumber, colNumber)?

Regards,
Suresh

Condor
7 Jan 2011, 4:53 AM
You need to write your own isCellEditable function that returns true or false depending on your conditions (and call the original isCellEditable for other columns).

ReSpawNnL
7 Jan 2011, 5:06 AM
If you are not using an EditorGridPanel, which I would advise doing since all editing is reversed (all can be edited, just supply a "editor:" with each column). Otherwise, just create a listener on the grid with "celldblclick" or "cellclick" and replace it's content with a TextField. Both events pass along the row- and cellIndex so it shouldn't be a problem. On "blur"/save, just fetch the store, get the record, reset the record with your new value, commit it and you're done!

Condor
7 Jan 2011, 5:13 AM
That's a lot of work for something that EditorGridPanel does by default. Why go through all that trouble?

What can't you do with EditorGridPanel that you can do with your own code?

ReSpawNnL
7 Jan 2011, 5:16 AM
That's a lot of work for something that EditorGridPanel does by default. Why go through all that trouble?

What can't you do with EditorGridPanel that you can do with your own code?
My point exactly. If you just want to edit only ONE column on each row, EditorGridPanel is still the best way to roll. :)

Condor
7 Jan 2011, 5:24 AM
But if you don't want all rows to be editable then just write a beforeedit event handler that returns false for the cells that shouldn't be editable or write your own isCellEditable method.

mitchellsimoens
7 Jan 2011, 6:06 AM
I would just assume Condor is right... he is about 99.9% of the time

Condor
7 Jan 2011, 6:22 AM
I would just assume Condor is right... he is about 99.9% of the time

I think it's more 98% correct, 1% typing errors, 1% plain wrong >:)

mitchellsimoens
7 Jan 2011, 6:30 AM
I think it's more 98% correct, 1% typing errors, 1% plain wrong >:)

haha... my bad /:)