diff --git a/demo-shell/resources/i18n/en.json b/demo-shell/resources/i18n/en.json index dafc492bcc..b7599604cb 100644 --- a/demo-shell/resources/i18n/en.json +++ b/demo-shell/resources/i18n/en.json @@ -196,7 +196,9 @@ "REPLACE_COLUMNS": "Replace columns", "LOAD_NODE": "Load Node", "MULTISELECT": "Multiselect", - "MULTISELECT_DESCRIPTION": "Use Cmd (Mac) or Ctrl (Windows) to toggle selection of multiple items" + "MULTISELECT_DESCRIPTION": "Use Cmd (Mac) or Ctrl (Windows) to toggle selection of multiple items", + "USE_CUSTOM_COLUMN_HEADER": "Use custom template for 'User' header", + "CUSTOM_COLUMN_HEADER": "Custom User Header Template" }, "ANALYTICS_REPORT": { "NO_REPORT_MESSAGE": "No report selected. Choose a report from the list" diff --git a/demo-shell/src/app/components/datatable/datatable.component.html b/demo-shell/src/app/components/datatable/datatable.component.html index 130b544dc2..1fe4a8fbc4 100644 --- a/demo-shell/src/app/components/datatable/datatable.component.html +++ b/demo-shell/src/app/components/datatable/datatable.component.html @@ -10,7 +10,7 @@ Sticky header -
+
--> + + +
+ + {{ 'DATATABLE.CUSTOM_COLUMN_HEADER'| translate }} + +
+
@@ -49,6 +57,7 @@
{{ 'DATATABLE.MULTISELECT'| translate }}
+

{{ 'DATATABLE.MULTISELECT_DESCRIPTION'| translate }}

@@ -59,9 +68,11 @@
-
+ +
+
diff --git a/demo-shell/src/app/components/datatable/datatable.component.scss b/demo-shell/src/app/components/datatable/datatable.component.scss new file mode 100644 index 0000000000..cc47d9f49b --- /dev/null +++ b/demo-shell/src/app/components/datatable/datatable.component.scss @@ -0,0 +1,13 @@ +.adf-datatable-demo-app { + height: 310px; + overflow-y: auto; + + &-actions { + display: flex; + column-gap: 4px; + } + + &-custom-user-header { + color: red; + } +} diff --git a/demo-shell/src/app/components/datatable/datatable.component.ts b/demo-shell/src/app/components/datatable/datatable.component.ts index b57448cb98..58b193c38c 100644 --- a/demo-shell/src/app/components/datatable/datatable.component.ts +++ b/demo-shell/src/app/components/datatable/datatable.component.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { Component, Input } from '@angular/core'; +import { Component, Input, ViewChild } from '@angular/core'; import { DataCellEvent, DataColumn, @@ -56,17 +56,20 @@ export class FilteredDataAdapter extends ObjectDataTableAdapter { @Component({ selector: 'app-datatable', - templateUrl: './datatable.component.html' + templateUrl: './datatable.component.html', + styleUrls: ['./datatable.component.scss'] }) export class DataTableComponent { + @Input() + selectionMode = 'single'; + + @ViewChild('customColumnHeaderTemplate') customColumnHeaderTemplate; + multiselect = false; data: FilteredDataAdapter; stickyHeader = false; - @Input() - selectionMode = 'single'; - selectionModes = [ { value: 'none', viewValue: 'None' }, { value: 'single', viewValue: 'Single' }, @@ -298,6 +301,21 @@ export class DataTableComponent { this.data.setColumns(columns); } + showCustomHeaderColumn() { + const columns = this.data.getColumns().map(column => { + if (column.title === 'Users') { + return { + ...column, + header: this.customColumnHeaderTemplate + }; + } + + return column; + }); + + this.data.setColumns(columns); + } + onShowRowActionsMenu(event: DataCellEvent) { const myAction = { title: 'Hello' diff --git a/lib/core/datatable/components/datatable/datatable.component.html b/lib/core/datatable/components/datatable/datatable.component.html index ddde207300..88a3423321 100644 --- a/lib/core/datatable/components/datatable/datatable.component.html +++ b/lib/core/datatable/components/datatable/datatable.component.html @@ -48,7 +48,6 @@ adf-drop-zone dropTarget="header" [dropColumn]="col">
- {{col.title | translate}} + + {{col.title | translate}} - - {{ getSortLiveAnnouncement(col) | translate: { string: col.title | translate } }} - + + {{ getSortLiveAnnouncement(col) | translate: { string: col.title | translate } }} + + + +
+ +
@@ -73,8 +78,6 @@
- -