Possible bug?

Possible bug?

greenjimmygreenjimmy Posts: 4Questions: 1Answers: 0

If I add a new row using an html tr and the method datatable.rows.add().draw() the columns don't sort properly based off of the html attributes (data-order) for the columns in that row.

Answers

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    Thanks for your question - however, per the forum rules can you link to a test case showing the issue please. This will allow the issue to be debugged.

    Information on how to create a test page, if you can't provide a link to your own page can be found here.

    Thanks,
    Allan

  • greenjimmygreenjimmy Posts: 4Questions: 1Answers: 0
  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    Nice one - thanks. So the problem here is that DataTables HTML5 orthogonal data is detected when the table is initialised. If there are no rows in the table then it can't be detected.

    There are two options:

    1. Add a row to the table with the required HTML and it will be auto detected
    2. Use columns.data to specify the orthogonal data. This is a bit ugly, but it can be done like this.

    Allan

  • greenjimmygreenjimmy Posts: 4Questions: 1Answers: 0

    So I can just add that row before initializing and delete it afterward?

  • greenjimmygreenjimmy Posts: 4Questions: 1Answers: 0

    Oh and thank you :)

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    Yup - you could do that and it will allow the auto detection to operate.

    Allan

This discussion has been closed.