diff --git a/projects/demo/src/app/pages/documentation/documentation.component.html b/projects/demo/src/app/pages/documentation/documentation.component.html index 91351a932..08a458a5b 100644 --- a/projects/demo/src/app/pages/documentation/documentation.component.html +++ b/projects/demo/src/app/pages/documentation/documentation.component.html @@ -88,6 +88,14 @@

'20px', '20%' + + hide + boolean + false + + Whether to hide this column or not + + editable boolean diff --git a/projects/ng2-smart-table/src/lib/components/tbody/tbody.component.html b/projects/ng2-smart-table/src/lib/components/tbody/tbody.component.html index 52a5fe81a..75859f45e 100644 --- a/projects/ng2-smart-table/src/lib/components/tbody/tbody.component.html +++ b/projects/ng2-smart-table/src/lib/components/tbody/tbody.component.html @@ -18,7 +18,7 @@ - + ): Array { + return (cells || []).filter((cell: Cell) => !cell.getColumn().hide); + } } diff --git a/projects/ng2-smart-table/src/lib/components/thead/rows/thead-filters-row.component.ts b/projects/ng2-smart-table/src/lib/components/thead/rows/thead-filters-row.component.ts index 143cabe7d..b73bfb5eb 100644 --- a/projects/ng2-smart-table/src/lib/components/thead/rows/thead-filters-row.component.ts +++ b/projects/ng2-smart-table/src/lib/components/thead/rows/thead-filters-row.component.ts @@ -12,7 +12,7 @@ import { Column } from "../../../lib/data-set/column"; [grid]="grid" (create)="create.emit($event)"> - + ): Array { + return (columns || []).filter((column: Column) => !column.hide); + } } diff --git a/projects/ng2-smart-table/src/lib/components/thead/rows/thead-form-row.component.ts b/projects/ng2-smart-table/src/lib/components/thead/rows/thead-form-row.component.ts index 87513ac4a..a61933bf6 100644 --- a/projects/ng2-smart-table/src/lib/components/thead/rows/thead-form-row.component.ts +++ b/projects/ng2-smart-table/src/lib/components/thead/rows/thead-form-row.component.ts @@ -2,6 +2,7 @@ import { Component, Input, Output, EventEmitter, OnChanges } from '@angular/core import { Grid } from '../../../lib/grid'; import { Row } from '../../../lib/data-set/row'; +import { Cell } from '../../../lib/data-set/cell'; @Component({ selector: '[ng2-st-thead-form-row]', @@ -10,7 +11,7 @@ import { Row } from '../../../lib/data-set/row'; - + ): Array { + return (cells || []).filter((cell: Cell) => !cell.getColumn().hide); + } } diff --git a/projects/ng2-smart-table/src/lib/components/thead/rows/thead-titles-row.component.ts b/projects/ng2-smart-table/src/lib/components/thead/rows/thead-titles-row.component.ts index 50f2166d3..fca559ae8 100644 --- a/projects/ng2-smart-table/src/lib/components/thead/rows/thead-titles-row.component.ts +++ b/projects/ng2-smart-table/src/lib/components/thead/rows/thead-titles-row.component.ts @@ -14,8 +14,10 @@ import { Column } from "../../../lib/data-set/column"; (click)="selectAllRows.emit($event)"> - + @@ -41,4 +43,7 @@ export class TheadTitlesRowComponent implements OnChanges { this.showActionColumnRight = this.grid.showActionColumn('right'); } + getVisibleColumns(columns: Array): Array { + return (columns || []).filter((column: Column) => !column.hide); + } } diff --git a/projects/ng2-smart-table/src/lib/lib/data-set/column.ts b/projects/ng2-smart-table/src/lib/lib/data-set/column.ts index 9a58445ed..69c71577f 100644 --- a/projects/ng2-smart-table/src/lib/lib/data-set/column.ts +++ b/projects/ng2-smart-table/src/lib/lib/data-set/column.ts @@ -6,6 +6,7 @@ export class Column { type: string = ''; class: string = ''; width: string = ''; + hide: boolean = false; isSortable: boolean = false; isEditable: boolean = true; isAddable: boolean = true; @@ -56,6 +57,7 @@ export class Column { this.title = this.settings['title']; this.class = this.settings['class']; this.width = this.settings['width']; + this.hide = !!this.settings['hide']; this.type = this.prepareType(); this.editor = this.settings['editor']; this.filter = this.settings['filter'];