Re-order table columns?

后端 未结 4 872
北荒
北荒 2021-02-03 10:55

Does anyone know a way to re-order table columns, using jQuery?

I don\'t mean sort - I mean dynamically move entire columns left or right in a table.

I\'m aware

4条回答
  •  北恋
    北恋 (楼主)
    2021-02-03 11:39

    Reading through the source code of the dragtable plugin, the author mentions that the algorithm for actually moving table columns was born of a discussion on the comp.lang.javascript newsgroup. That discussion is here: Swapping table columns.

    In that thread, the OP is not asking about the UI side of reordering, but help with debugging a function he'd already written to swap two columns. Further down the discussion it develops into code that enables you to pass a specific column ordering, and have the code calculate all the necessary swaps/moves to get from the current ordering to the specified ordering.

    It's not jQuery (most posters on c.l.js have a firm dislike of it and most other JS frameworks), and therefore it's code you can hopefully adapt for your needs and then include anywhere.

提交回复
热议问题