View Full Version : Getting a Grid cell to be editable sometimes

3 Jul 2007, 10:59 AM
I am trying to have an editor grid cell that when clicked is editable if it is part of a new record, not one fetched from the database, but inserted into the data store without being committed ever (not just dirty, new).

However, the same cell can not be edited if it is part of a fetched record, even if the record is dirty.

I determine if the record is new by the ID field. If the ID field is marked 'NEW" then I know that an id hasn't been created for the record (that is done when it is saved).

So here's the problem:
I am not sure the best place to do the check to allow the editor to enable/disable. I'm asking more of a design question - what is a proper way to do this?

I tried several solutions - none seemed to work quite right. My latest was to subclass textfield and handle this in the onFocus. This just doesn't feel like a great solution and I'm having problems with it so before I spent another few hours trying to fix it I thought I would ask if there is an easier / better solution.

3 Jul 2007, 11:01 AM
You can add a handler for beforeEdit and return false or e.cancel=true if it's not editable.

3 Jul 2007, 11:08 AM
See - I knew it was easier. I promise I read the docs and the boards first! I'll let you know if it works and thanks!

5 Jul 2007, 9:39 PM
Yes it worked. Thanks!