Editor is not setting row id in post parameters
Editor is not setting row id in post parameters
mass6
Posts: 7Questions: 3Answers: 0
I'm using DOM sourced tables, and in the HTML, I set the row id programmatically to match the records primary key. My table looks as follows:
<table id="suppliers-table" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Primary Contact</th>
<th>Email</th>
<th>Phone</th>
<th>Fax</th>
<th>Website</th>
</tr>
</thead>
<tbody>
<?php foreach($company->associatedSuppliers as $supplier) { ?>
<tr id="row_{{ $supplier->id }}">
<td>{{ $supplier->name }}</td>
<td>{{ $supplier->primary_contact }}</td>
<td>{{ $supplier->email }}</td>
<td>{{ $supplier->telephone1 }}</td>
<td>{{ $supplier->fax }}</td>
<td>{{ $supplier->website }}</td>
</tr>
<?php } ?>
</tbody>
</table>
But, when I edit a record and send the ajax post request, the row is undefined.
action:edit
data[undefined][name]:Stamm-Hauck
data[undefined][primary_contact]:Mrs. Maud Jacobs DDS
data[undefined][email]:mina.lind@balistreri.org
data[undefined][telephone1]:+44(0)9494 30636
data[undefined][fax]:+44(0)752562578
data[undefined][website]:kling.com
I check the page source I can see that the tr id is being set correctly, but Editor is not picking it up. Am I missing something?
This discussion has been closed.
Answers
Actually, after checking the DOM Sourced Table example on this site, the error appears here as well. So, the example code with DOM sourced tables seems to be incorrect. When checking the post parameters, the row id is undefined in the example here as well.
I am having this same issue. Row ID is blank in request to server when using DOM sourced table and REST interface.
It only started happening to me after I upgraded to 1.5.1.
I did some more testing using the online example, and I found that if you create a new record, you can then edit it and the row id gets populated in the Ajax post parameters. So, it seems that Editor is just not reading the DOM on initial load, but it does pick up on any further updates to the DOM.
Hi,
Yes, I'm afraid that this is an issue in DataTables 1.10.9 - it doesn't correctly read the row ids from the DOM, so Editor can't itself them use them.
The nightly version of DataTables has a fix for this and it will be included in the 1.10.10 release.
Regards,
Allan
Thanks for the quick response, Allan. I'll keep an eye out for the 1.10.10 release.
Cheers. :)
Hi guys,
I have the same problem with the nightly version, though it looks like it is because the id attribute is removed from the DOM.
If I deactivate javascript, I can see
<tr id="28018">
but if I reactivate javascript, I have no ID<tr role="row" class="even">
Hence I have
data[undefined][name]
in the body of the POST request.Am I missing something?
Could you try the DataTables nightly please? If that doesn't resolve the issue, can you give a link to the page showing the issue. I presume you are DOM loading the initial table and then all updates are performed by Ajax?
Allan
Hi Allan,
I added a
DT_RowId
field and loaded everything through Ajax, not pre-populating the first page, and it worked fine on the nightly and the latest release.What made it work in the end for me was to load everything on Ajax, otherwise I couldn't have it working on either release.
Lionel