Is there a prescribed approach to preventing the idSrc from being changed in editor's update dialog?
Is there a prescribed approach to preventing the idSrc from being changed in editor's update dialog?
Hi,
I realize I can mock something up that will work for me.
But, I'd much prefer to use any prescribed Datatables Editor (version 1.5) approach to doing what I feel is a common need in this area of data maintenance on a web page. Especially, if you're dealing with a "natural" key in the UI and you want to protect it from being updated by the end-user.
This works below, but it has flaws (e.g., the UI doesn't place the cursor in the first non-key field being the biggest issue):
editor.on('onInitEdit', function () {
// if doing an edit, then we want to only show the key not allow it to be changed.
editor.disable('ID');
});
Any other suggestions would be much appreciated!
Thanks,
Mike
This question has an accepted answers - jump to answer
Answers
I have a fully customized way of doing things that work for me. I'm posting this custom solution just in case anyone else would need this.
I'm still interested if Datatables staff and/or Allan would have a better way at accomplishing the same.
Mike
The "DataTables staff" is just me :-).
I think there are two options:
disable()
. You can then usefield().focus()
to set the focus orform-options
which I think would be slightly better. Also an important point - I would suggest you never read anything from the.s
object. That is internal to Editor and considered to be private - you won't see it documented anywhere. Also the properties in it can, will and do change between versions. Usemode()
to find out want editing mode Editor is in.show()
andhide()
which will resolve the focus issue.The reason that this isn't more obvious in the Editor API is that setting the ID on create is something that is typically left to the database.
Regards,
Allan
Hi Allan,
Wow... you are the entire staff... gees - amazing!
What you said makes sense to a degree.. but I'm not sure how to tell if it is a "create" or an "edit" without the .s object. Is there a way to do that properly with a single editor instance?
Thanks so much for all your help!
Mike
Use the
mode()
API method.Allan
Sorry I missed that from your first response - thanks for all the assistance on this one! :-)