How to dynamically show/hide datatable columns based on dataset ?

Hi ,

I want to show or hide one column (i.e Contacts) in my below snippet :

https://snippet.webix.com/tpzs0sdf

When I use mydata_short, the Contacts column should not be shown.
How can I use autoConfig to dynamically control this based on my dataset (i,e mydata or mydata_short) ?

Thanks

Hello,

I should note that autoConfig form columns based on the dataset, which is coming the first time. So you need to track which dataset came to datatable, and then use hideColumn to hide/show certain column.
https://snippet.webix.com/ettlfazo

Also, you can redefine the datatable. Please check the info. But there is important to use webix.copy
https://snippet.webix.com/70hn4dwe

Hi Nastja,

I got to know about autoConfig to show/hide columns in datatable from this post https://forum.webix.com/discussion/2957/dynamic-columns-of-datatable#latest

However, was not sure how to use that, so I mentioned about it.

Considering my problem, I think your first solution will help me show/hide the column , by following way as you mentioned here in your answer :

  • first inspect the dataset if it has that column id or not?
  • then use $$(‘mytable’).hideColumn(“id3”);

I will try and let you know. Thanks a lot.