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

Hide show rows

Open TeodorKolev opened this issue 8 years ago • 1 comments

Is there any option for hiding and showing rows? How can I implement that? Thank you

TeodorKolev avatar Jun 02 '17 11:06 TeodorKolev

Well, there no is straight way of hiding/showing rows, but I can show you my workaround:

    public config: any = {}
    private data: Array<any> = [];
    private initData: Array<any> = [];

    this.service.getUsersForTable().then(data => {
        this.data = data;
        this.initData = JSON.parse(JSON.stringify(this.data));
        this.onChangeTable(this.config);
    });

    hideFirstRow() {
        this.data = this.data.filter((x, i) => i !== 0);
        this.onChangeTable(this.config);
    }

    showAll() {
        this.data = this.initData;
        this.onChangeTable(this.config);
    }

Create two variables, the first will be used to remove/add items in it and the second one is the initial data which we can use any time. Of course you can create third variable to store the "hidden" items. I made two simple function that illustrate how can you "hide"/"show"items from the table.

mbtakanov avatar Jun 30 '17 09:06 mbtakanov