Get table id on which ColVis is activated

Get table id on which ColVis is activated

MaiorovYuryMaiorovYury Posts: 4Questions: 0Answers: 0
edited December 2013 in General
Hi, everyone
I have a question. Basically, I am using ColVis with fnFilter. And when I hide a column, I want to cancel this filter.
I was able to change _fnDomColumnButton function inside ColVis.js file to do that.
But now I faced an issue, when I have 2 or more tables on a page - how do I know which table this function relates to? So basically, how inside this function I can get id of a table on which it runs?

Replies

  • MaiorovYuryMaiorovYury Posts: 4Questions: 0Answers: 0
    Anyone?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    DataTables 1.10 (pre-beta currently) fires the event `column-visiblity.dt` ( https://github.com/DataTables/DataTables/blob/master/media/js/jquery.dataTables.js#L13948 ) when a column changes visibility. That might be the way forward.

    Otherwise if you are having ColVis you should be able to use `settings.nTable.id` where `settings` is the DataTables settings object.

    Allan
  • MaiorovYuryMaiorovYury Posts: 4Questions: 0Answers: 0
    Allan,
    thank you very much!
    Not knowing that I had to add another parameter to ColVis initialization. But this way is much better!
This discussion has been closed.