PDA

View Full Version : Validation in EditorGridPanel



v.madhu
28 Mar 2010, 11:06 PM
Hello,
In EditorGridPanel has 2 columns are TextFeild editable.
I also implemented validateedit event for cell validation.

Here is the scenario.
When i edit the cell in first column (assume i entered wrong value and validation fails)
and tabout, validateedit event calls and it returns false.

What is happening is while tabbingout the cursor focuses to the next editable column and starts editing.

I want to change this behaviour. If validation fails i want to focus in the same cell and not to focus on the next editable cell.

Thanks in advance for the reply.

v.madhu
29 Mar 2010, 4:34 AM
Any comments on this question?

Condor
29 Mar 2010, 5:20 AM
Wouldn't that be extremely annoying for users that enter an invalid value and can't exit the cell editor (e.g. to cancel the window) until they enter a valid value again?

I once write a plugin that would mark any invalid values in the grid (the same as invalid fields in a form). However, I don't know if that still works on the current Ext version...

v.madhu
29 Mar 2010, 6:28 AM
Thanks, for the response Condor. You are right it didn't make sense. But the requirement was like that.

For the solution, i was trying to Override CellSelectionModel (fn handleKeyDown ) the place where to navigate away from that cell. But didn't successed 100%

fay
29 Mar 2010, 6:43 AM
Can you not just write a beforeedit (http://www.extjs.com/deploy/dev/docs/?class=Ext.grid.EditorGridPanel&member=beforeedit) handler for the second cell and then check if the first has been modified and is "valid" before allowing the handler to continue?

Condor
29 Mar 2010, 7:14 AM
Can you not just write a beforeedit (http://www.extjs.com/deploy/dev/docs/?class=Ext.grid.EditorGridPanel&member=beforeedit) handler for the second cell and then check if the first has been modified and is "valid" before allowing the handler to continue?

No, you can't because by the time the beforeedit event is fired the original editor has already reverted to it's previous valid value.

This is rather complicated to do. All occurrences of a startEditing call (without a true parameter) will first need to check if the current editor is valid.
And no, overriding startEditing doesn't work, because the calling methods need to stop their processing if the current editor isn't valid.