3.2.0

Confused about the purpose of validation event handlers on grid cells

Hi Alex,

I have to say that I'm really, really impressed with the product.

I am mid-level (3+ yrs experience) PHP and JS programmer, and pretty much a complete newbie to AJAX programming. It's great to start with a well-designed toolkit like yours.

Right now, however, I am a bit puzzled by a problem that I'm having. Let me explain.

I am using the grid control to let our users edit a very short DB table on our server. I very much like the idea of having a change to an editable cell be committed to the server as soon as you blur from the cell.

All that works fine and dandy, until I try to implement my error handling... what happens if something goes wrong on the server side?
I have managed to have the server generate a well-formed XML doc that I parse using the DOM, and I can pop up alerts with detailed status on the error. However...

The newly typed text stays on the cell!!! I don't want this, the change didn't make it into the DB. I want the old text back in there. I had high hopes that event handlers such as onCellValidating or onCellValidated would PREVENT the typed text from being shown if one returned false from their assigned functions. However, this is completely ineffectual. If one returns false from either of these handlers, onCellEditEnding and obj.onCellEditEnded proceed in sequence as if nothing had happened.

Is there a way to tell the grid

"look, NO! This entry doesn't validate! ABORT!" ??

That's what the event handler's name suggests it would do.

More to the point, is there a way to just revert to the old text if the newly-typed one didn't make it into the server? How would you go about this.

And (sorry) one further question: if those event handlers don't do what I think they do, could you briefly exlpain their purpose?

Thanks, and congratulations again on an outstanding product.

QUASAR
Quasar
July 29,
If you return non-zero error code from onCellValidating() event handler - the value will be considered as invalid and the cursor will stay in the cell requiring either pressing ESC to go back to the original value or correcting the error (see examples/new/editing.htm).

The onCellValidated() event happens after the cell is validated. If you want to restore the oroginal text at this point - use setCellText(text, col, row).
Alex (ActiveWidgets)
July 31,
Alex,

thanks a lot for your pormpt reply.

AFTER posting this message, I found the following, which I want to cite for future reference, in case people are looking for a solution to this same problem:

http://www.activewidgets.com/javascript.forum.13440.3/accessing-old-value.html

Also, thanks so much for the tip on using setCellText. It wasn't working for me becuase I was giving it the args in the wrong order (col, row, text). Is the name and order of the args for each function anywhere in the docs? I've found that the Class Refereces only have the method names, but their arguments.

Anyway, thanks again!

Cheers,

QUASAR
Quasar
July 31,

This topic is archived.

See also:


Back to support forum