Skip to content

Commit 7833afe

Browse files
committed
feat(docs): add the new QTable props (table-row-style-fn & table-row-class-fn) to one of the styling examples #8311
1 parent cb4866a commit 7833afe

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

docs/src/examples/QTable/CustomColor.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
<div class="q-pa-md">
33
<q-table
44
color="primary"
5-
card-class="bg-amber-5 text-brown"
6-
table-class="text-grey-8"
5+
card-class="bg-orange text-grey-10"
6+
table-class="text-grey-1"
77
table-header-class="text-brown"
8+
:table-row-class-fn="rowClassFn"
9+
:table-row-style-fn="rowStyleFn"
810
flat
911
bordered
1012
title="Treats"
@@ -142,7 +144,15 @@ export default {
142144
setup () {
143145
return {
144146
columns,
145-
rows
147+
rows,
148+
149+
rowClassFn (row) {
150+
return row.calories % 2 === 0 ? 'bg-brown' : 'bg-primary'
151+
},
152+
153+
rowStyleFn (row) {
154+
return row.calories % 2 === 0 ? 'color:#ccc' : 'color:#fff'
155+
}
146156
}
147157
}
148158
}

docs/src/pages/vue-components/table.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ Pay attention to the code in the "style" section in the following examples, espe
157157

158158
<DocExample title="Custom column" file="CustomColumn" />
159159

160+
::: tip
161+
For all the styling component properties, please check the API card at the top of the page.
162+
:::
163+
160164
<DocExample title="Custom coloring" file="CustomColor" />
161165

162166
<DocExample title="No header/footer" file="NoHeaderFooter" />

ui/src/components/table/QTable.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@
565565

566566
"table-row-style-fn": {
567567
"type": "Function",
568-
"desc": "CSS style to apply to the table rows (which are TR elements)",
568+
"desc": "CSS style to apply to the table rows (which are TR elements); For best performance, reference it from your scope and do not define it inline",
569569
"params": {
570570
"row": {
571571
"type": "Object",
@@ -587,7 +587,7 @@
587587

588588
"table-row-class-fn": {
589589
"type": "Function",
590-
"desc": "CSS class(es) to apply the table rows (which are TR elements)",
590+
"desc": "CSS class(es) to apply the table rows (which are TR elements); For best performance, reference it from your scope and do not define it inline",
591591
"params": {
592592
"row": {
593593
"type": "Object",
@@ -654,7 +654,7 @@
654654

655655
"card-style-fn": {
656656
"type": "Function",
657-
"desc": "(Grid mode only) CSS style to apply to the row/record card; Has no effect when the 'item' slot is used",
657+
"desc": "(Grid mode only) CSS style to apply to the row/record card; Has no effect when the 'item' slot is used; For best performance, reference it from your scope and do not define it inline",
658658
"params": {
659659
"row": {
660660
"type": "Object",
@@ -676,7 +676,7 @@
676676

677677
"card-class-fn": {
678678
"type": "Function",
679-
"desc": "(Grid mode only) CSS class(es) to apply the row/record card; Has no effect when the 'item' slot is used",
679+
"desc": "(Grid mode only) CSS class(es) to apply the row/record card; Has no effect when the 'item' slot is used; For best performance, reference it from your scope and do not define it inline",
680680
"params": {
681681
"row": {
682682
"type": "Object",

0 commit comments

Comments
 (0)