ColVis - Fire an event
ColVis - Fire an event
Hi,
I'm using DataTables with the colVis plugin, I really like both!
I read the documentation, but I think I missed something: I'd like to do execute something when the element that permits to choose columns (.ColVis_collection) disappear, but I'm not able to do this.
Alternatively, I could execute my code when a column is select/deselected, but I prefer the first alternative.
Does anyone have any hint?
Thanks in advance to anyone who will answer,
bye!
I'm using DataTables with the colVis plugin, I really like both!
I read the documentation, but I think I missed something: I'd like to do execute something when the element that permits to choose columns (.ColVis_collection) disappear, but I'm not able to do this.
Alternatively, I could execute my code when a column is select/deselected, but I prefer the first alternative.
Does anyone have any hint?
Thanks in advance to anyone who will answer,
bye!
This discussion has been closed.
Replies
At the moment the way to do this would be:
1. Edit the code to fire the event you want
2. Use fnDrawCallback and count the number of visible columns to see when the visible column count has changed and then apply your custom function.
Allan
first thank for your answer, I'm happy you added those things to your to do list! :)
Second I used what you suggested me, but there is something strange:
when I select/deselect a column, the event is called just once, as it should be, but when the table is drawn for the first the event is called twice. Is this the right behavior?
For the record, I'm using DataTables 1.9.1 and ColVis 1.0.7.
My dataTables element is configured like this:
[code]
var table_acct = $('#display').dataTable({
"oLanguage":{
"sShowAll": "Show all",
"sSearch": "Search" ,
"sZeroRecords":"No records:"
},
"bPaginate": false,
"bLengthChange": false,
"bFilter": true,
"bSort": false,
"bInfo": false,
"bAutoWidth": false,
"bStateSave": true,
"iCookieDuration": 604800,
"sScrollX": "100%",
"sScrollXInner": "150%",
"bScrollCollapse": true,
"sDom": 'C<"clear">lfrtip',
"oColVis": {
"aiExclude": [ 0 ],
"buttonText":"Show or hide"
},
"aoColumns":[ {"bSearchable": true}, {"bSearchable": false},{"bSearchable": false},{"bSearchable": false},
{"bSearchable": false},{"bSearchable": false},{"bSearchable": false},{"bSearchable": false},
{"bSearchable": false},{"bSearchable": false},{"bSearchable": false},{"bSearchable": false},
{"bSearchable": false},{"bSearchable": false},{"bSearchable": false} ],
"fnDrawCallback": function(){
console.log("redraw");
}
});
new FixedColumns(table_acct,{iLeftColumns:1, "iLeftWidth": 160});
[/code]
Did I do something wrong?
Bye
Allan
I'll try to find something to avoid the double call.
Maybe, as my table is filled with data obtained with an ajax call, I should use the approppriate datasource, even if I use the data obtained to other purposes too. :)
I'll try to find a way to do this.
Thanks allan.