data[0] (hidden column) returns expected data[1] value
data[0] (hidden column) returns expected data[1] value
WernerCloete
Posts: 16Questions: 2Answers: 0
Good morning
I build a table dynamically, as with my example at https://jsfiddle.net/WernerCloete/m23akdjb/103/.
When I remove the row, after updating the database with the new data, data[0] returns the data[1] value, not the expected ID value (the example does not have this problem).
I have no idea why this would happen. If I don't convert the table, using
$("table#test").DataTable(
{
"bAutoWidth": false,
"columnDefs":
[
{
"targets": [ 0 ],
"visible": false,
"searchable": false
}
],
"lengthMenu": [ 5, 10, 25, 50, 75, 100 ],
"order": [[ 1, "asc" ]],
"select":
{
"style": "single"
}
});
the table shows that the ID column and row values are present.
This discussion has been closed.
Answers
In my project code, when I do a
I get
and then, when I do a
I get
so it appears that the table is located, but when I try to remove the current row, data[0] returns an incorrect (data[1]) value...and, when I try to add the new row, the new row is not added.
Row removal code:
Row addition code:
I added some code, to my project, in order to view the table values.
The logging, from line 17:
The logging, from line 43:
Why would column 0 disappear?
I've updated my JsFiddle, at https://jsfiddle.net/WernerCloete/m23akdjb/204/, placed the table in a tab, as it is in my project code, added additional table manipulation code, as in my project, but the JsFiddle code works and my project code does not.
This is quite frustrating...
To be honest, I did not analyze all your code, but your last comment that it is working in jsFiddle and not in your project might be a problem of your cache (I had a lot of problems with related to the cache). Maybe your project is still working on an older version of your JavaScript. So give it a try to clean your cache and then reload your project.
Good day
I've already done that, quite a few times (I had a similar thought), but it did not work.
jQuery:
DataTables:
I just noticed something else:
Even though I'm using
my table is converted over and over again (every time I to update the row - also happening in my JsFiddle example). I don't understand why this is happening.
I updated my JsFiddle to https://jsfiddle.net/WernerCloete/m23akdjb/206/, added
and now that does not appear any more. It still does not explain why
did not work...
I created a work-around, "jumping down" the hierarchy:
I have to use "body", if no modal is shown, as I have tables on the page that users can click on to open the modals.
From there I can now use