Show hide columns dynamically with Multiple tables on tabbed content

Show hide columns dynamically with Multiple tables on tabbed content

anaganag Posts: 48Questions: 2Answers: 7
edited October 2011 in General
Hi i'm using show hide dynamic columns. My page has tabbed content with a table on each tab each with a unique ID. Just above each table I have a drop down button that lists the columns of that specific table. How do I initialize the function so it takes affect on each table, and how would I write the code so that one of my drop down menus won't affect the column vis of another table.

Will I have to create a unique function for each tab?

[code]
function fnShowHide( iCol )
{
/* Get the DataTables object again - this is not a recreation, just a get of the object */
var oTable = $('#keywords').dataTable();

var bVis = oTable.fnSettings().aoColumns[iCol].bVisible;
oTable.fnSetColumnVis( iCol, bVis ? false : true );
}
[/code]

Replies

  • GregPGregP Posts: 487Questions: 8Answers: 0
    I suspect the way you've declared var oTable inside your function will indeed re-initialize the table, not get the existing object. "var" is wiping the oTable variable clean, and $.().dataTable() is making a new object to fill that variable.
  • anaganag Posts: 48Questions: 2Answers: 7
    I ended up creating a unique function for each tab / table
This discussion has been closed.