Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
`,
styleUrls: ['./tree-grid-shared.scss'],
})
export class TreeGridSortableComponent {
customColumn = 'name';
defaultColumns = [ 'size', 'kind', 'items' ];
allColumns = [ this.customColumn, ...this.defaultColumns ];
dataSource: NbTreeGridDataSource;
sortColumn: string = '';
sortDirection: NbSortDirection = NbSortDirection.NONE;
constructor(private dataSourceBuilder: NbTreeGridDataSourceBuilder) {
this.dataSource = this.dataSourceBuilder.create(this.data);
}
changeSort(sortRequest: NbSortRequest): void {
this.dataSource.sort(sortRequest);
this.sortColumn = sortRequest.column;
this.sortDirection = sortRequest.direction;
}
getDirection(column: string): NbSortDirection {
if (column === this.sortColumn) {
return this.sortDirection;
}
return NbSortDirection.NONE;
}
@Component({
selector: 'nb-tree-grid-showcase',
templateUrl: './tree-grid-showcase.component.html',
styleUrls: ['./tree-grid-shared.scss', './tree-grid-showcase.component.scss'],
})
export class TreeGridShowcaseComponent {
customColumn = 'name';
defaultColumns = [ 'size', 'kind', 'items' ];
allColumns = [ this.customColumn, ...this.defaultColumns ];
dataSource: NbTreeGridDataSource;
sortColumn: string;
sortDirection: NbSortDirection = NbSortDirection.NONE;
constructor(private dataSourceBuilder: NbTreeGridDataSourceBuilder) {
this.dataSource = this.dataSourceBuilder.create(this.data);
}
updateSort(sortRequest: NbSortRequest): void {
this.sortColumn = sortRequest.column;
this.sortDirection = sortRequest.direction;
}
getSortDirection(column: string): NbSortDirection {
if (this.sortColumn === column) {
return this.sortDirection;
}
return NbSortDirection.NONE;
}