You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You must wrap the table data inside `useResource$`, and the return element inside `Resource`. To put it in other frameworks' language: **The data must be memoized**.
| tData | Record[]| Table data _(must be memoized)_. | ✅ |
131
-
| transformHeads | boolean | Checkbox if you want to transform your data params to headings (ie. turn "date_received" to "Date Received"). Support both `snakeCaseParams` and `camel_case_params`. | ❌ (default = `true`) |
132
-
| tailwindClasses | boolean | Checkbox if you want to include the library's default Tailwind classes to the return components. You can always customize the classes using `accessor` (see below). | ❌ (default = `true`) |
| tData | Record[]| Table data _(must be memoized)_. | ✅ |
164
+
| transformHeads | boolean | Checkbox if you want to transform your data params to headings (ie. turn "date_received" to "Date Received"). Support both `snakeCaseParams` and `camel_case_params`. | ❌ (default = `true`) |
| tHeadings.props | { [key: string]: JSXChildren } | Add props to all <th> tags. | ❌ |
167
+
| tHeadings.props.class | string | Add class list to all <th> tags. For `TailwindCSS` users, you can change your classes here. | ❌ (default = `"table-heading"`) |
168
+
| tHeadings.accessor | QRL<(heading: string) => JSX.Element> | Render custom JSX elements inside all <th> tags. | ❌ |
| tRows.props | { [key: string]: JSXChildren } | Add props to all <tr> tags. | ❌ |
171
+
| tRows.props.class | string | Add class list to all <tr> tags. For `TailwindCSS` users, you can change your classes here. | ❌ (default = `"table-row"`) |
| tCells.props | { [key: string]: JSXChildren } | Add props to all <td> tags. | ❌ |
174
+
| tCells.props.class | string | Add class list to all <td> tags. For `TailwindCSS` users, you can change your classes here. | ❌ (default = `"table-cell"`) |
|`<THead />`|`component$`| List of table headers. Must be wrapped in <thead> tag. |
184
+
|`<TBody />`|`component$`| Table body. Must be wrapped in <tbody> tag. |
185
+
186
+
### 3. Methods
187
+
188
+
These methods support sophisticated table functions apart from generating table data. They can be imported directly from the library, same as `tableLoader`.
|`param2string()`| str: `string`| Convert `snake_case_param` or `camelCaseParam` to string. Used in table headings. |
193
+
|`string2param()`| str: `string`, method: `"snake" or "camel"`| Convert string to `snake_case` or `camelCase`, opposed to `param2string()` method. |
194
+
|`sortTable()`| data: `Record[]`, param: `string`, isAcending: `boolean`| Sort table data with given heading (`param`) in ascending order (isAcending=`true`) or descending (isAcending=`false`). |
195
+
|`searchTable()`| data: `Record[]`, params: `string[]`, keyword: `string`| Search table data base with given headings (`params`) and keyword (`keyword`). Can be used in search or filter inputs. |
196
+
|`getTotalPages()`| total_record: `number`, record_per_page: `number`| Calculate total pages. Can be used in paginating table records. |
197
+
198
+
## Tips
199
+
200
+
- Make sure to name your param in your data in either `snake_case` or `camelCase` for `transformHeads` feature to work properly...
201
+
202
+
```typescript
203
+
const data = {
204
+
name: "Jon Doe", // OK
205
+
date_of_birth: "1990/01/01", // OK
206
+
timeZone: "UTC+08:00", // OK
207
+
// ...
208
+
}
209
+
```
210
+
211
+
- The table `props` property has type `[key: string]: JSXChildren` in which `JSXChildren` does NOT include `QRL`. Therefore, you should only add basic `props` such as ID or class; for event handlers like `onClick$` or `onFocus$` for example, try to add those in a separate element in the `element$` property instead.
212
+
213
+
- Check out some examples located in the folder `/example` in the library.
0 commit comments