TypeError: Cannot set properties of undefined (setting '_DT_CellIndex')

TypeError: Cannot set properties of undefined (setting '_DT_CellIndex')

Rupesh BharukaRupesh Bharuka Posts: 9Questions: 1Answers: 0

Error messages shown:
TypeError: Cannot set properties of undefined (setting '_DT_CellIndex')

Description of problem:
In a dataTable that has 0 entries, but has a column with no title or a title of just ( ). (For example a column for action buttons that has no title), this causes a JS error like in original report.

This issue is immediately resolved once the amount of rows in table is greater than 0.

Replies

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

    Sounds like your table doesn't meet the requirements of what Datatables needs. See the HTML docs. Please provide a link to your page or a test case replicating the issue so we can help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • Rupesh BharukaRupesh Bharuka Posts: 9Questions: 1Answers: 0

    Got it. I've changed my code a bit. Now, I'm getting this error because of colspsan that I've used in my tbody. The below example is the exact same scenario, kindly refer to it & guide me accordingly. Thanks

    Demo Link: http://live.datatables.net/rexixevu/60/edit

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    DT does not support colspan in a tbody.

    Please also note that while DataTables supports colspan and rowspan in the table's header and footer, they are not supported in the table's tbody and must not be present.

    https://datatables.net/manual/installation#HTML

  • Rupesh BharukaRupesh Bharuka Posts: 9Questions: 1Answers: 0

    do we have any workaround to this issue or we shall keep it as is and wait for the client to add at least 1 record to the table to get rid of this issue?

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

    You can show an empty table. You can use language.emptyTable to change the text displayed when the table is empty.

    Kevin

  • Rupesh BharukaRupesh Bharuka Posts: 9Questions: 1Answers: 0

    @kevin I personally didn't like this approach. Instead, datatable should address this issue of colspan in tbody as the issue is faced by multiple users. And, I think this should be taken as a high priority issue because this is a basic functionality of a table when it comes to web application.

    Also, what is strange here is, datatable doesn't support colspan in table body but it supports the same in the table header and footer according to @tangerine above. But, when it comes to the arrangement of data in a table, we do that in the table body. The rest is just a piece of decorative information. So, according to me, this is a must fix in a data table library. Correct me, if I'm wrong.

    Thanks, Rupesh

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

    I think the main reason for not supporting colspan and rowspan in the tbody is for sorting and searching. Having either of these would make it more complex and would make it more complex for developers to create custom searching and sorting plugins.

    Kevin

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

    So, according to me, this is a must fix in a data table library. Correct me, if I'm wrong.

    Yep, you're wrong :) As Kevin said, colspan and rowspan in the table body would significantly impact ordering and filtering, so it's not something that's going to happen in the short-term.

    Colin

  • Rupesh BharukaRupesh Bharuka Posts: 9Questions: 1Answers: 0

    Oh, thanks @kthorngren and @colin for the clarification on this. I completely agree with both of you & understand the significant impact on ordering and filtering features of the data table.

Sign In or Register to comment.