Skip to content

Commit

Permalink
feat(Table): handle rowClass property in columns (#1632)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Trost <[email protected]>
  • Loading branch information
galexrt authored Jul 23, 2024
1 parent f74f1df commit 748e491
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/content/2.components/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Use the `columns` prop to configure which columns to display. It's an array of o
- `sortable` - Whether the column is sortable. Defaults to `false`.
- `direction` - The sort direction to use on first click. Defaults to `asc`.
- `class` - The class to apply to the column cells.
- `rowClass` - The class to apply to the data column cells.
- `sort` - Pass your own `sort` function. Defaults to a simple _greater than_ / _less than_ comparison.

::component-example{class="grid"}
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/components/data/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<UCheckbox v-model="selected" :value="row" v-bind="ui.default.checkbox" aria-label="Select row" @click.stop />
</td>

<td v-for="(column, subIndex) in columns" :key="subIndex" :class="[ui.td.base, ui.td.padding, ui.td.color, ui.td.font, ui.td.size, row[column.key]?.class]">
<td v-for="(column, subIndex) in columns" :key="subIndex" :class="[ui.td.base, ui.td.padding, ui.td.color, ui.td.font, ui.td.size, column?.rowClass, row[column.key]?.class]">

Check failure on line 74 in src/runtime/components/data/Table.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 20)

Property 'rowClass' does not exist on type 'Column | { key: string; label: Capitalize<string>; sortable: boolean; class: any; sort: (a: any, b: any, direction: "desc" | "asc") => 0 | 1 | -1; }'.
<slot :name="`${column.key}-data`" :column="column" :row="row" :index="index" :get-row-data="(defaultValue) => getRowData(row, column.key, defaultValue)">
{{ getRowData(row, column.key) }}
</slot>
Expand Down Expand Up @@ -121,6 +121,7 @@ interface Column {
sort?: (a: any, b: any, direction: 'asc' | 'desc') => number
direction?: 'asc' | 'desc'
class?: string
rowClass?: string
[key: string]: any
}
Expand Down

0 comments on commit 748e491

Please sign in to comment.