ColReorder throwing Requested unknown parameter; Trying to debug but getting stuck

ColReorder throwing Requested unknown parameter; Trying to debug but getting stuck

Mik_raterMik_rater Posts: 12Questions: 4Answers: 0

Link to test case:
I would link to my proper test case as I am trying to debug this issue, but I can't even get ColReorder to work in the JS Bin
http://live.datatables.net/goqivebu/1/edit
All I get is Script Error (Line: 0) When I include ColReorder, so I must be missing something?

Debugger code (debug.datatables.net):
The result from running the debugger is a 404 page, so I'm unsure what to do here.
https://debug.datatables.net/agarix

Error messages shown::
DataTables warning: table id=results_table - Requested unknown parameter 'undefined' for row 0, column 14. For more information about this error, please see http://datatables.net/tn/4

Description of problem:
Other than the above problems I am getting with the debugging tools above.

My issue is that after changing the way our data comes into datatables whenever a user moves a column using the ColReorder feature it throws the above message.

This code used to work and even when the error gets thrown the table still functions normally.
I would appreciate any ideas on what this issue might be and how it could be solved!
Thank you!

This question has accepted answers - jump to:

Answers

  • colincolin Posts: 15,112Questions: 1Answers: 2,583
    edited March 2021 Answer ✓

    The order of the library is important - see here where I've ensured ColReorder comes after the DataTables libraries.

    It's all working there now, so can you update the example to reflect your issue, please.

    Colin

  • Mik_raterMik_rater Posts: 12Questions: 4Answers: 0

    Thank you Colin you legend!
    I didn't realise that the JS bin didn't put them in order, now I feel silly.

    And using the JsBin I was able to solve my issue. However I am still not too sure what is happening.
    (I Solved my issue by changing the way I feed the data in)

    I have managed to distill the problem down to this:
    I am skipping putting some of the data into the column field, but it is still going into the data field.

    And this is what is causing it to error when I try to move the columns.

    http://live.datatables.net/xacagure/1/edit
    (Hit runJs before trying to move columns, otherwise the browser seems to throw an error)

    While my actual problem is now gone, any insight onto what is happening in the JsBin would be very helpful!

    Thank you!

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓

    Interesting! It looks like ColReorder isn't coping with a sparse array for the column indexes. If you look at your columns definition object it has:

    When ColReorder sees that the data source is an array, it just shuffles the array, causing the data array to contain 0, 1, 2, 3 indexes, but the data source is still looking for index 4, thus the error.

    What you could do in that example is rather that remapping the column defs and data, is to create the column you don't want to see, but just mark it as hidden: http://live.datatables.net/xacagure/3/edit .

    Allan

  • Mik_raterMik_rater Posts: 12Questions: 4Answers: 0

    Ah thank you Allan, that seems to both explain and solve my issues.
    I now have those columns hidden and everything seems good.

    Again, many thanks!

This discussion has been closed.