mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-30 11:47:55 +01:00
docs(table): add additional custom sort details (#2234)
This commit is contained in:
@@ -32,6 +32,18 @@ Use the `columns` prop to configure which columns to display. It's an array of o
|
|||||||
- `rowClass` - The class to apply to the data column cells. :u-badge{label="New" class="!rounded-full" variant="subtle"}
|
- `rowClass` - The class to apply to the data column cells. :u-badge{label="New" class="!rounded-full" variant="subtle"}
|
||||||
- `sort` - Pass your own `sort` function. Defaults to a simple _greater than_ / _less than_ comparison.
|
- `sort` - Pass your own `sort` function. Defaults to a simple _greater than_ / _less than_ comparison.
|
||||||
|
|
||||||
|
Arguments for the `sort` function are: Value A, Value B, Direction - 'asc' or 'desc'
|
||||||
|
|
||||||
|
Example `sort` function:
|
||||||
|
```
|
||||||
|
(a, b, direction) => {
|
||||||
|
if (!a || !b) return 0
|
||||||
|
const aPrice = parseInt(a.replace(/[,$]/g, ""))
|
||||||
|
const bPrice = parseInt(b.replace(/[,$]/g, ""))
|
||||||
|
return direction === "asc" ? aPrice - bPrice : bPrice - aPrice
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
::component-example{class="grid"}
|
::component-example{class="grid"}
|
||||||
---
|
---
|
||||||
extraClass: 'overflow-hidden'
|
extraClass: 'overflow-hidden'
|
||||||
|
|||||||
Reference in New Issue
Block a user