Parent child editor - child editor do not trigger update query
Parent child editor - child editor do not trigger update query
Hello,
I am trying to implement the parent child editor but fail to update the child.
I tryied both methods:
* https://editor.datatables.net/examples/datatables/parentChild
* https://editor.datatables.net/examples/advanced/parentChild / https://datatables.net/blog/2016/parent-child-editing
For both:
1. I can see and update the parent table
2. I can see the childs of the each parent
3. BUT when I try to update a child, nothing happens. I can only see with the debug that no UPDATE query runs.
Is anyone able to locate what is missing or wrong?
I copy / pasted the code from the examples and adapted it several times, but it always leads to the same result.
Thanks and regards,
Christophe
Answers
here is my code for the fist method:
here is my code for the second method
Hi Christophe,
Can you link to the page you are working on so I can take a look please? You can PM it to me if you don't want to make the link public.
Allan
Hello Allan,
I managed to fix it.
Hard to say what the problem was because I started several times from scratch, but I think the issue was that part.
Question for you: is there a way to be able to create a child at the same time as creating the parent?
Not really - not using nested Editors like that at least. The nested Editor is async to the host Editor, it submits and then returns control to the host.
Allan
Any idea for a workaround that would work like: upon creation of the parent, the parent would close and reopen automatically?
It depends on what you mean by "at the same time". Do you mean a single Ajax request?
I had assumed that you where looking for the child row to be local (i.e. on the browser only) until the parent form is submitted. Is that what you are looking to do?
That would be difficult to do in Editor. At least not with out a large amount of custom code for the submit handler and on the server-side.
Allan
Hi @allan,
Is https://datatables.net/forums/discussion/comment/211255 similar to this request? If you treat the child data as a json object that's modified via a nested datatable with no ajax, then you just need to handle that object on the backend. Yes?
Are there any official examples of modifying a nested json field and submitting it along with the parent?
Yes, that could be done. Setup the child DataTable as a local table. There is a limitation in
datatable
at the moment in that it expects the field value to be an array of scalars, rather than an array of objects, but that is a trivial change if this is needed. The reason it is setup that way is I expected thedatatable
to be used for left joined or Mjoined data primarily.However:
Sorry, no. That is not something that the Editor server-side libraries are designed to handle. I suspect it would be possible to do with a bunch of loops over the submitted data, but it isn't something that I have tried I'm afraid.
Allan