Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Commit 75606ac

Browse files
committed
feat: ability to set th and td class names in a UiTable column definition
1 parent cb406f9 commit 75606ac

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

addon/components/ui-table/template.hbs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ input of the next tier down.
8383
@description={{column.description}}
8484
@recordSet={{Filter.filteredRecords}}
8585
@sortCriterion={{Sorter.Criterion}}
86+
class={{column.thClassName}}
8687
/>
8788
{{/each}}
8889
</tr>
@@ -91,14 +92,23 @@ input of the next tier down.
9192

9293
<tbody>
9394
{{#if (has-block "row")}}
94-
{{#each (if this.pagingEnabled Pager.pageRecords Filter.filteredRecords) as |record index|}}
95-
{{yield record index to="row"}}
95+
{{#each (if this.pagingEnabled Pager.pageRecords Filter.filteredRecords) as |record rowIndex|}}
96+
{{yield record rowIndex to="row"}}
9697
{{/each}}
9798
{{else if this.columns}}
98-
{{#each (if this.pagingEnabled Pager.pageRecords Filter.filteredRecords) as |record|}}
99+
{{#each (if this.pagingEnabled Pager.pageRecords Filter.filteredRecords) as |record rowIndex|}}
99100
<tr>
100-
{{#each this.columns as |column|}}
101-
<td>{{get record column.propertyName}}</td>
101+
{{#each this.columns as |column columnIndex|}}
102+
{{#if column.tdComponent}}
103+
{{component column.tdComponent
104+
column=column
105+
record=record
106+
rowIndex=rowIndex
107+
columnIndex=columnIndex
108+
}}
109+
{{else}}
110+
<td class={{column.tdClassName}}>{{get record column.propertyName}}</td>
111+
{{/if}}
102112
{{/each}}
103113
</tr>
104114
{{/each}}

addon/components/ui-table/th/component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default class UiTableTh extends Component {
2727

2828
public recordSet?: unknown[];
2929

30-
public showColumnFilter = true;
30+
public showColumnFilter = false;
3131

3232
protected declare sortCriterion: UiSorterCriterion;
3333

addon/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import type Controller from '@ember/controller';
2+
import type EmberComponent from '@ember/component';
3+
import type GlimmerComponent from '@glimmer/component';
24

35
export type DirectionsX = Directions.Left | Directions.Right;
46

@@ -33,6 +35,9 @@ export interface ITableColumn {
3335
filterStartsWith?: boolean;
3436
filterCaseSensitive?: boolean;
3537
filterBooleanMap?: [string, string];
38+
thClassName?: string;
39+
tdClassName?: string;
40+
tdComponent?: string | typeof EmberComponent | typeof GlimmerComponent;
3641
}
3742

3843
export enum Directions {

0 commit comments

Comments
 (0)