Not able to initialize table
Not able to initialize table
Hi,
I have a page with few tables, they are dynamically generated and generally based on one of two templates.
I am trying to use DataTables in order to get sorting and filtering on my page.
For the tables from the first template, everything is OK, but the initialization is failing for the other tables with this error: "SCRIPT5007: Unable to get property 'mData' of undefined or null reference".
I looked at the other discussions and I made sure that the number of column are matching and there are THEAD and TBODY tags.
What else can be causing this problem? It's happening on line 1184, "if (col.mData === i)", this is related to the first row in the body, I believe.
My tables are wrapped in few other tables/div, I tried removing some layers, doesn't make any diff so far.
Thanks,
Simon
Answers
Can you post a link to your page or a test case so we can take a look? I believe this error is generally due to the Datatable config not matching the HTML table.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Hi Kevin,
The whole page is a part of a business application with sensitive content, but may be I can copy some of the tables after I filter the content somewhat.
What does it mean "Datatable config not matching the HTML table"?
Thanks,
Simon
That would be if the column count in the header and footer don't match the column count in the table (you said you verified that already), or if the naming of the columns doesn't match what's being returned in the JSON.
But as Kevin said, if that doesn't help, we would really need to see the table to progress this efficiently.
Cheers,
Colin
Hi,
Here is the table that is working (some row removed):
and here is the one that is failing:
Thank you,
Simon
Looks like the first table has 6 columns and the second has 7 columns. Are you using the same Datatables init code for both tables? Please post the init code.
Kevin
Yes, my tables have different number of columns.
I trimmed all of my complex customization down to: table.DataTable(); same error.
My init function is hooked like this:
$(function () {
setupIntTables();
});
-S
Unfortunately there isn't enough info to guess what the problem might be. Can you put together a simple test case replicating the problem, please?
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Just need simulated data, etc.
Kevin
Problem found - I typed "head" instead of "thead" as the tag name, my mistake.