Two Joins Datatables Editor Undefined index
Two Joins Datatables Editor Undefined index
Hello,
I'm trying to adapt this example https://datatables.net/forums/discussion/26095/full-editor-for-multiple-child-rows#Comment_71585 to my datatables.
There's a problem : "Undefined index p2b_detail on line 16 " when I submit edit data on the child table. The MySQL data was updated, but the child datatables won't refresh.
Line 16: $filter = $_POST['data']['p2b_detail']['p2b_nr'];
My code
$filter = isset($_GET['p2b_nr'])?$_GET['p2b_nr']:0;
if ( isset($_POST['action']) && $_POST['action'] === 'edit' ) {
$filter = $_POST['data']['p2b_detail']['p2b_nr'];
}
Please advise, i'm trying to rewrite all code, but the problem still appear.
This question has an accepted answers - jump to answer
Answers
The error you are seeing suggests that the
p2b_detail
field(s) is not being submitted to the server. Are you using inline editing here? If so, have you set thesubmit
option of theform-options
toallIfChanged
? Otherwise, only the changed value will be submitted.Allan
hi allan,
i'm not using inline editing. I'm using form.
If the p2b_detail field(s) is not being submitted to the server, why i've got an update after error. As i wrote on my question above, after i clicked the submit button, error appear, the data was updated (on MySQL). But the child datatables (#p2b_detail) not refreshed.
When i closed the form and refresh the page, the child datatables (#p2b_detail) shown the updated value
Please help, thank you
Are you able to give me a link to the page please? The data format your code uses above is expecting data to be submitted in the legacy format. Is that correct? Have you configured Editor to submit in the legacy format (
legacyAjax
)?If you could link to the page that would be really helpful in being able to resolve this issue.
Thanks,
Allan
Sorry Allan, it's on my localhost.
I'm new in datatables, i just searching on this forum and found that link above to show 2 join datatables in one page. I didn't see any
legacyAjax: true
on that example link, so i guess that's not legacy.Or maybe there is any example for my need? I want to create 2 datatables, master detail on one page
Please advise, thank you
Okay - let's take a step back. What is the goal here? Do you want to apply a condition to the data that is loaded? What are you using to submit that data?
Allan
Sorry late reply,
As on my debug link, I want to create a master-detail tables on one page.
Master tables : Table (#p2b_head)
Detail tables: Table (#p2b_detail)
After browsing this forum, i found this link https://datatables.net/forums/discussion/26095/full-editor-for-multiple-child-rows#Comment_71585
so i tried to adopt to my tables.
- Both datatables works
- Submit New Button both datatables works
- Submit Edit Button master tables works
- Submit Edit Button detail table error : "Undefined index p2b_detail on line 16 " , datatables not refreshed, but MySQL is updated
Line 16: $filter = $_POST['data']['p2b_detail']['p2b_nr'];
The goal is success edit and refresh the datatables. Please advise, thank you
or maybe, is there any example editor one to many join table on Child Row Datatables like this example http://datatables.net/examples/api/row_details.html
If you are not submitting in the legacy format, there will be no
$_POST['data']['p2b_detail']
parameter (as the error suggests).This page documents the format that data is submitted in. Note that it is an object of data for each row.
I would suggest reading this blog post which I think (hope!) will address the issues that you are seeing. It details how parent / child editing can be implemented.
Allan
Hello Allan,
Parent / Child editing is what i need. Thanks for the link.
I'm trying to adapt that example to my page, then i found problem on selecting parent table, the child table won't show to linked row
Please take a look on my code, what's wrong.
Debug page
My script
My php code
Can you link to a page showing the issue so I can debug it live please?
Allan
Here's the link Allan, please take a look
thank you
This is returning
undefined
. Your data object's structure is:So you would use:
Allan
thanks allan