ng2-table icon indicating copy to clipboard operation
ng2-table copied to clipboard

Add / remove cols dynamically

Open GaillardQ opened this issue 8 years ago • 8 comments

Hi, I am meeting a problem about adding/removing columns dynamically... I update the columns variable, but the cols are still displayed in the table....

Quentin

GaillardQ avatar Jan 12 '17 13:01 GaillardQ

Hey, If you are trying to update the columns at runtime then make sure that after updating columns you must call onChangeTableFunction

this.onChangeTable(this.config);

According to its functionality it will rerender html. It will works for you I hope

Hasnain-Bukhari avatar Jan 17 '17 06:01 Hasnain-Bukhari

do you have any update on this.

ervbsankar avatar Feb 07 '17 21:02 ervbsankar

Doesn't work for me..

tosehee75 avatar Feb 21 '17 22:02 tosehee75

Nope - doesn't work for me either

rsksmiles avatar Mar 15 '17 21:03 rsksmiles

Did you solve this?

anafreitas avatar Mar 23 '17 12:03 anafreitas

No - I replaced it with ngPrime data table.

rsksmiles avatar Mar 23 '17 12:03 rsksmiles

maybe in 2022

TeodorKolev avatar Dec 18 '17 11:12 TeodorKolev

Dummy workarond:

    <div *ngIf="columns.length == 9">
      <ng-table [config]="config"
                ...
                [columns]="columns"
                [totals]="totals"
                [pageTotals]="pageTotals">
      </ng-table>
    </div>
    <div *ngIf="columns.length != 9">
      <ng-table [config]="config"
                ...
                [columns]="columns"
                [totals]="totals"
                [pageTotals]="pageTotals">
      </ng-table>
    </div>

Or you can use whatever boolean you need

TeodorKolev avatar Dec 18 '17 11:12 TeodorKolev