angular-datatables icon indicating copy to clipboard operation
angular-datatables copied to clipboard

Hide/show columns

Open giolvani opened this issue 12 years ago • 13 comments

There is any way to hide or show columns after the table has been rendered?

I know it is possible using fnSetColumnVis from oInstance, but it will be perfect if I could use this feature from DTColumnBuilder, ex:

//columns definition
$scope.dtColumns = [
    DTColumnBuilder.newColumn('...')...
    ...
];

//so this command 
$scope.dtColumns[0].setVisible(false);
$scope.dtColumns[3].setVisible(true);

Tks

giolvani avatar Nov 05 '14 17:11 giolvani

I think the best way is to use the colVis plugin. You won't need to define manually in the code which column is visible or not.

l-lin avatar Nov 05 '14 18:11 l-lin

I forgot to mention the colVis!

I don't would like to use the colVis, I think it is low customizable, at least, I couldn't custom it my way.

giolvani avatar Nov 05 '14 18:11 giolvani

You can do it directly by setting the visible to false:

$scope.dtcolumns[0].visible = false;
$scope.dtcolumns[3].visible = true;

Angular-datatables can change the options seamessly.

l-lin avatar Nov 05 '14 19:11 l-lin

:(

It doesn't worked for me!

2014-11-05 17:44 GMT-02:00 Louis LIN [email protected]:

You can do it directly by setting the visible to false:

$scope.dtcolumns[0].visible = false; $scope.dtcolumns[3].visible = true;

Angular-datatables can change the options seamessly.

— Reply to this email directly or view it on GitHub https://github.com/l-lin/angular-datatables/issues/117#issuecomment-61868929 .

Att. Giolvani de Matos

giolvani avatar Nov 05 '14 19:11 giolvani

Mmh looks like it's only working with columnDef...

l-lin avatar Nov 05 '14 21:11 l-lin

Fixed on the upcoming version 0.4.0.

l-lin avatar Jan 18 '15 13:01 l-lin

How to get this change I am also stuck on this

shukla2009 avatar Jan 18 '15 21:01 shukla2009

The v0.4.0 is not out yet. But the changes are all in the dev branch.

l-lin avatar Jan 18 '15 21:01 l-lin

Thanks :) any expected date for v0.4.0 ?

shukla2009 avatar Jan 18 '15 21:01 shukla2009

There are still some issue to deal with. So it will be out when there are done.

l-lin avatar Jan 18 '15 21:01 l-lin

I tried this approach, but for whatever reason I couldn't figure out,

the first time you do $scope.dtcolumnDef[0].visible = false; it works perfect and pretty quick, but when you try to do it again, it's extremely slow, ex. taking more than 1 seconds.

windmaomao avatar Feb 23 '16 21:02 windmaomao

i have try this '$scope.dtcolumns[0].visible = false;' but getting error. i want to column hide and show on conditionally how can do any idea?

Coderwill avatar Apr 03 '17 11:04 Coderwill

@Coderwill Worked for me.. you need to capitalize the "c" in columns. vm.dtColumns[0].visible = false;

rnunez100 avatar Aug 18 '17 18:08 rnunez100