Looking for a colreorder event or proxy

Looking for a colreorder event or proxy

khaoskhaos Posts: 47Questions: 11Answers: 0

Datatables v1.12.1

test case: https://jsfiddle.net/Cyberjetx/hgvtqxux/47/

After creation all the filtering works as expected. If you reorder a column the filter's context is no longer the proper column data. I need to re-index the swapped columns with the API assuming (colReorder.transpose()) which is preferred as it will likely retain any existing selections.
- or
- Rebuild the filter UI as I have built in this example.

The end goal is to fix the filter. If there is a better way to trigger than I have discovered I am ready for the answer. :)

This question has an accepted answers - jump to answer

Answers

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

    You can use colReorder.transpose() for that - as it maps the original index to the current. See your updated example here, and this is the important code,

            let idx = dtable.colReorder.transpose(column.index(), 'toCurrent');
            dtable.column(idx)
              //.search(val ? '^' + val + '$' : '', true, false)
              .search(val, true, false)
              .draw();
    

    Colin

  • khaoskhaos Posts: 47Questions: 11Answers: 0

    That is great. Thanks.

Sign In or Register to comment.