Having trouble getting shared control in ColVis to work

Having trouble getting shared control in ColVis to work

huangm777huangm777 Posts: 7Questions: 0Answers: 0
edited September 2011 in Bug reports
I'm trying to get the ColVis plugin to work over three separate tables. I tried using the example code on this page:

http://www.datatables.net/release-datatables/extras/ColVis/two_tables_identical.html

However, while it does limit the display to one set of controls, it only affects the first table, and not the others.

I notice, too, that the example page itself doesn't seem to have a working ColVis control either. It's not even visible on both Firefox and Chrome.

Another issue: putting oColVis options inside the oTable = $('table').dataTable() block doesn't seem to affect the final rebuild of the table when oColVis.fnRebuild() is invoked later (as in the example code block). Is there a way to make sure that any options I set for oColVis inside there will get passed into the rebuild? Perhaps in the constructor for a new ColVis object? Maybe I just haven't looked in the right documentation.

Here's the code blocks I'm working with.

[code]
$(document).ready(function() {
var oTable = $('table').dataTable( {
"aaSorting": [],
"bSort": false,
"bPaginate": false,
"aoColumns": [
{ "mDataProp": "feature" },
...
],
"aoColumnDefs": [ { "bVisible": false, "aTargets": [5,6,7,8,9,10,11] } ],
"sDom": '<"clear">rt',
"oColVis": {
"aiExclude": [0,1,2],
"sSize" : "css"
}
} );
var oColVis = new ColVis( oTable.fnSettings() );
$(oColVis).bind('stateChange', function (e, data) {
var jqTables = $('table');
for ( var i=0, iLen=jqTables.length; i

Replies

  • huangm777huangm777 Posts: 7Questions: 0Answers: 0
    edited September 2011
    I've investigated further. It seems that the event handler code inside $(oColVis).bind() actually never runs! And I'm not sure why, either. But it really does seem at least when I debug it in Firebug, the event handler function code isn't executed, either on load or when I click a checkbox in the show/hide columns. Perhaps this is the issue? (For one, I'm not sure 'stateChange' is an event...)

    Does anyone have a similar problem and can help me out? I've got a deadline tomorrow...Thanks.

    Michael
  • huangm777huangm777 Posts: 7Questions: 0Answers: 0
    Never mind. It looks like the code in the page source itself—as opposed to the example code on
    http://www.datatables.net/release-datatables/extras/ColVis/two_tables_identical.html

    is the correct code after all! That worked.

    You definitely should update the example code however on that page. It's non-operational.

    Michael
  • bhaskarbhaskar Posts: 1Questions: 0Answers: 0
    Michael,
    Thanks for sharing your experience. I had the same trouble, spent a couple of hours on it and found your comment. Thanks!
This discussion has been closed.