ColVis Menu + ColReorder + Button colvis problem
ColVis Menu + ColReorder + Button colvis problem
Hi everyone!
I'm now trying to migrate from old TableTools to the new Buttons and everything, and a problem arise that I don't know how fix.
Here is my situation: I'm using ColVis, ColReorder and Buttons, one of the Buttons is 'colvis' which when pressed, shows a dropdown with all my columns, visible ones highlighted. That's all cool for now.
But, when I reorder columns, dragging some of them around, that Button's dropdown starts acting strange. Order of elements in that menu isn't updated, and when I click on some element, say, 'Name' entry, the corresponding column 'Name' is indeed hidden in the background. But here's the problem: entry 'Name' in the menu stays highlighted, and some other entry (looks like the one that corresponds to a new index of the 'Name' column in the table) is unhighlighted.
And my question is: am I missing some setup or that is an incompatibility problem? Is it possible to update a list of columns in the Buttons menu when columns are reordered or at least synchronize their highlighted status?
I use this code to include datatables into my test page:
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/u/ju-1.11.4/jq-2.2.3,jszip-2.5.0,pdfmake-0.1.18,dt-1.10.12,b-1.2.1,b-colvis-1.2.1,b-flash-1.2.1,b-html5-1.2.1,b-print-1.2.1,cr-1.3.2,fc-3.2.2,fh-3.1.2,kt-2.1.2,r-2.1.0,rr-1.1.2,sc-1.4.2,se-1.2.0/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/u/ju-1.11.4/jq-2.2.3,jszip-2.5.0,pdfmake-0.1.18,dt-1.10.12,b-1.2.1,b-colvis-1.2.1,b-flash-1.2.1,b-html5-1.2.1,b-print-1.2.1,cr-1.3.2,fc-3.2.2,fh-3.1.2,kt-2.1.2,r-2.1.0,rr-1.1.2,sc-1.4.2,se-1.2.0/datatables.min.js"></script>
My table is defined like this:
var _table = self.__table.DataTable( {
"processing": true,
"sPaginationType": "full_numbers",
"bStateSave": true,
"orderMulti": true,
"sScrollX": "100%",
"sDom": 'Bfr<"clear">iptip',
"aoColumns": self.columns,
colReorder: {
"fixedColumns": 1
},
"order": self.sort_col,
colVis: {
"exclude": [ 0 ],
"sAlign": "right",
"buttonText": "Show / hide columns",
"bRestore": true,
},
buttons: [ 'pageLength',
'colvis',
'colvisRestore',
'copy',
'csv',
'excel',
'pdf',
'print', ],
"bSortCellsTop": true,
"iDisplayLength": 25,
lengthMenu: [[5, 10, 25, 50, 100, -1], [5, 10, 25, 50, 100, "All"]],
});
UPD: I've been able to reproduce that behavior here:
http://live.datatables.net/javemey/26/edit?html,js,output
Just try to move columns around and then turn them on and off with the menu Column Visibility at the top.
This question has an accepted answers - jump to answer
Answers
Thanks for posting this - I'm afraid the non-reordering of the columns in the
colvis
button type is a know issue. It was proving surprisingly difficult to make work, although the changes I've made to buttons recently might actually make it a lot easier.The other issue is a new bug - sorry! I'll post back here when I've had a chance to fix it (probably next week).
Allan
Fixed here and the nightly will rebuild with the change in the next 5 minutes.
Thanks for flagging this up.
Regards,
Allan
(cross link to thread that also discusses this issue)