Not able to initialize table

Not able to initialize table

sipanevsipanev Posts: 5Questions: 1Answers: 0

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

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    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

  • sipanevsipanev Posts: 5Questions: 1Answers: 0

    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

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    What does it mean "Datatable config not matching the HTML table"?

    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

  • sipanevsipanev Posts: 5Questions: 1Answers: 0
    edited October 2019

    Hi,

    Here is the table that is working (some row removed):

    Zone VM Family Segment Valid from Reason Approved by
    0 DV2SERIES benqAMSMSDN 05/31/2019 MiniCapacity email@dom.com
    0 DV2SERIES benqAMSBIZSPARKPLUS 05/31/2019 MiniCapacity email@dom.com
    0 DV2SERIES INTERNALRD 05/31/2019 MiniCapacity email@dom.com
    0 DV2SERIES benqAMSOTHER 05/31/2019 MiniCapacity email@dom.com
    0 DV2SERIES benqAMSBIZSPARK 05/31/2019 MiniCapacity email@dom.com
    0 DV2SERIES TRIAL 05/31/2019 MiniCapacity email@dom.com
    0 FSERIES INTERNALRD 05/31/2019 MiniCapacity email@dom.com
    0 STANDARDD15V2 benqAMSOTHER 11/22/2018 LimitedSku email@dom.com

    and here is the one that is failing:

    0 Action Zone VM Family Segment Reason Approved by
    0 ADD 0 FSV2SERIES devint 77 88
    0 ADD 0 FSV2SERIES benqAMSMSDN 77 88
    0 ADD 0 FSV2SERIES benqAMSBZSPRK 77 88
    0 ADD 0 FSV2SERIES TRIAL 77 88
    0 ADD 0 FSV2SERIES INTERNALNONRD 77 88
    0 ADD 0 STANDARDDS15V2 DIRECT 77 88
    0 ADD 0 STANDARDDS15V2 EA 77 88
    0 ADD 0 STANDARDD15V2 EA 77 88

    Thank you,
    Simon

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    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

  • sipanevsipanev Posts: 5Questions: 1Answers: 0

    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

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    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

  • sipanevsipanev Posts: 5Questions: 1Answers: 0

    Problem found - I typed "head" instead of "thead" as the tag name, my mistake.

This discussion has been closed.