ng2-table
ng2-table copied to clipboard
Hide show rows
Is there any option for hiding and showing rows? How can I implement that? Thank you
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.