Moving rows up and down.
Moving rows up and down.
Im trying to add functionality to my datatable with buttons that:
* move row to the top of the table
* move row one position up in the table
* move row down one position in the table
* move row to the bottom of the table.
And im not sure about how to accomplish this with this datatable component.
I tried to manipulate the DOM directly with jQuery and managed to get the rows to move like I want, but as soon as the datatable has trigged a redraw event all changes to the datatable DOM is reset and redrawn from the datasource as it was in the original data. Does Datatable have any methods for manipulating the data it operates on like this, moving rows around?
* move row to the top of the table
* move row one position up in the table
* move row down one position in the table
* move row to the bottom of the table.
And im not sure about how to accomplish this with this datatable component.
I tried to manipulate the DOM directly with jQuery and managed to get the rows to move like I want, but as soon as the datatable has trigged a redraw event all changes to the datatable DOM is reset and redrawn from the datasource as it was in the original data. Does Datatable have any methods for manipulating the data it operates on like this, moving rows around?
This discussion has been closed.
Replies
[code]
function moveSelectedUp(){
var arr = jQuery('#table tbody tr.selected_row')
for(var i=0; i
I have reimplemented my code above to manipulate the order how aoData is drawn by manipulate fnSettings.aiDisplay instead of moving data around is aoData. Works very nicely. Not sure what to do when my users decides that they must have filtering and sorting.. :)
What I would suggest for integrating this with filtering and user sorting, is to consider using aaFixedSorting on a hidden column. This will allow you to force DataTables to always order by a given column (the hidden one) first, before doing the user ordering. In the hidden column have an index counter which will define the order you want.
Allan