How do I manually update DB after validation and before new values are read?
How do I manually update DB after validation and before new values are read?
kevan.watkins
Posts: 22Questions: 5Answers: 0
PreEdit event is now fired before validation
PostEdit event is fired after new values are read from DB
I have some fields that need to be updates through membership provider, etc and not directly by Editor.
So how do I update these only if server-side validation passes, and before the new values are read?
Do I need to alter the Values, already read from DB, to be returned to client in PostCreate?
Kind regards,
Kevan
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi Kevan,
This, I fear, is currently a missing feature. It is not something that Editor yet supports, but it is something that I am aware of.
Having said that, the
preEdit
event should happen after the validation, but it will happen before the row is written to the database. edit this is incorrect - see belowpostEdit
will happen after the row has been written to the database, but also after Editor has read the data back.Adding an event in between the two is something I plan to introduce soon (might make it into 1.6.2 as I can see how useful it could be).
Any suggestions for a name for the event?
writeEdit
?Allan
Hi Allan,
writeEdit works for me.
In the meantime I'll work around it by reading the fields from the DB and updating e.Data manually in PostEdit. Then clean that up when the new event is added.
Or.. is there an easy way to trigger verification from within PreEdit?
Both are hacks, but I need to demo this week.
I started with our most complicated table as a test. All working great, so we'll be buying two developer licenses in the next few days.
Thanks for a great product and for the support
kevan
Hi Kevan,
My apologies. My statement that the
preEdit
should happen after the validation is completely wrong. It has to happen before the validation so that extra validators can be dynamically added if required!The quickest hack I can think of to make this "work" is to use the
PostEdit
to update the database as you had planned, then on the client-side useajax.reload()
when Editor has updated the table:There will be a small flash of the data missing the extra information from the
PostEdit
and you'll have the overhead of an extra Ajax request, but the advantage is that when I do add this feature you can just remove that little bit of Javascript and update the event name on the server-side to make it work properly.Regards,
Allan