1

Do you know how to dynamically/later hide or show column when datatable's source is javascript?

this method works for tables created with html source but not with method created with javascript source?

 var table = $('#example').dataTable({
  "data": source,
  "columns": columns,
  "columnDefs": [
  {
    "targets": [ 0 ],
    "visible": false, // no worries for hiding column at start 
  });
    var col = table.column("1").visible(false); //error if source is javascript
1
  • my second ? is an error Commented Feb 9, 2015 at 1:42

1 Answer 1

1

I finally found out we can do like that:

 table.fnSetColumnVis(3, false);

It works when table is create with method datatable (old version)

in spite of column() wroks when table is created with method Datatable (new version)

Sign up to request clarification or add additional context in comments.

2 Comments

It does not work because you initialize dataTables the "old" way, with dataTable(). column() should be used when using the new dataTables 1.0.x API, eg DataTable(). It is perfectly well to accept your own answer, perhaps it will help other people in the future.
of thank you very much !!! you solved the mystery! I was becoming crazy! Your solution is better! you should write it as answere.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.