I am using DataTables along with the rowReorder plugin against a static table (non AJAX) - everything initialises fine but when I drag a row, whilst it moves within the tabl
This is getting a bit aged, but I had to work through it and thought I'd share what I did. My requirements had this a table with sortable rows, but ordering by header click was not a requirement and made the UI a bit confusing.
The HTML is a fairly standard table.
HTML
Position
Valid Characters
Is Literal Character
0
1
2
3
4
The javascript is also fairly straight forward. The major difference is the addition of a draw event handler. This iterates the header fields and strips the class tag, and also removes the click handler. This code was called from a page onload hander.
JAVASCRIPT
function removeSorting() {
$.each($('#maskEditTable').find('thead > tr > th'), function (i, header) {
$(header).attr('class', null);
$(header).off('click');
});
}
function() init(){
var tab = $('#maskEditTable')
.DataTable({
paging: false,
info: false,
searching: false,
rowReorder: {
selector: 'tr',
update: true
},
order: [[0, "asc"]],
columnDefs: [
{
targets: 0,
visible: true
}
]
});
tab.on('draw.dt', removeSorting);
removeSorting();
}
The results are exactly what I was expecting and there is no visible effects on the redraw in any of my tests.
GL!
- 热议问题