Skip to content

Commit e983d50

Browse files
authored
Merge pull request #151 from NMFS-RADFish/208-doc-add-default-sort-content
208 doc add default sort content
2 parents 0066dd8 + ba52092 commit e983d50

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

docs/design-system/custom-components/table.md

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ For a practical implementation, refer to the [Simple Table Example](https://gith
2929
| **`columns`** | `Array<Object>` | Defines the structure and configuration of the table columns. |
3030
| **`paginationOptions`** | `Object` | Provides options for handling pagination, such as `pageSize`, `currentPage`, `totalRows`, and `onPageChange`. |
3131
| **`onRowClick`** | `function` | A callback function triggered when a table row is clicked. |
32+
| **`defaultSort`** | `Array<Object>` | Sets the default sorting for the table, with each object specifying a key for the column and direction ("asc" or "desc"). |
3233
| **`className`** | `string` | An optional `className` for custom styling. |
3334

3435
#### Trussworks Table Props
@@ -107,8 +108,8 @@ import { Table } from "@nmfs-radfish/react-radfish";
107108
```jsx
108109
<Table
109110
data={[
110-
{ id: 1, name: "Alice", age: 32, image: "https://picsum.photos/150/75" },
111-
{ id: 2, name: "Bob", age: 28, image: "https://picsum.photos/150/75" },
111+
{ id: 1, name: "Alice", age: 32, image: "example-img.png" },
112+
{ id: 2, name: "Bob", age: 28, image: "example-img.png" },
112113
]}
113114
columns={[
114115
{ key: "name", label: "Name", sortable: true },
@@ -137,8 +138,8 @@ import { Table } from "@nmfs-radfish/react-radfish";
137138
```jsx
138139
<Table
139140
data={[
140-
{ id: 1, name: "Alice", age: 32, image: "https://picsum.photos/150/75" },
141-
{ id: 2, name: "Bob", age: 28, image: "https://picsum.photos/150/75" },
141+
{ id: 1, name: "Alice", age: 32, image: "example-img.png" },
142+
{ id: 2, name: "Bob", age: 28, image: "example-img.png" },
142143
]}
143144
columns={[
144145
{ key: "name", label: "Name", sortable: true },
@@ -165,13 +166,38 @@ import { Table } from "@nmfs-radfish/react-radfish";
165166

166167
![Table Example Screenshot](/img/example-table-onClickRow.gif)
167168

168-
## Trussworks Table Props
169+
### defaultSort Prop
169170

170171
```jsx
171172
<Table
172173
data={[
173-
{ id: 1, name: "Alice", age: 32, image: "https://picsum.photos/150/75" },
174-
{ id: 2, name: "Bob", age: 28, image: "https://picsum.photos/150/75" },
174+
{ id: 1, firstName: "Alice", lastName: "Smith", age: 25 },
175+
{ id: 2, firstName: "Bob", lastName: "Jones", age: 30 },
176+
{ id: 3, firstName: "Charlie", lastName: "Smith", age: 20 },
177+
{ id: 4, firstName: "Dave", lastName: "Jones", age: 40 },
178+
{ id: 5, firstName: "Eva", lastName: "Brown", age: 35 },
179+
]}
180+
columns={[
181+
{ key: "firstName", label: "First Name", sortable: true },
182+
{ key: "lastName", label: "Last Name", sortable: true },
183+
{ key: "age", label: "Age", sortable: true },
184+
]}
185+
defaultSort={[
186+
{ key: "lastName", direction: "asc" },
187+
{ key: "firstName", direction: "desc" },
188+
]}
189+
/>
190+
```
191+
192+
![Table Example Screenshot](/img/example-table-defaultSort.png)
193+
194+
### Trussworks Table Props
195+
196+
```jsx
197+
<Table
198+
data={[
199+
{ id: 1, name: "Alice", age: 32, image: "example-img.png" },
200+
{ id: 2, name: "Bob", age: 28, image: "example-img.png" },
175201
]}
176202
columns={[
177203
{ key: "name", label: "Name", sortable: true },
63.7 KB
Loading

0 commit comments

Comments
 (0)