-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/table sortable field #1477
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@devara hmm... Any example to use this with list from API? And also, i see this can be sorting using multiple fields at once? but how if we want to use with only single field? In most API we have, it's accept only single |
@adenvt , if use list from the API, items on the table will not be sorted immediately, just emit the sorted key & value, so page/component that use the Table comp can do the desired action (I already add the prop for sortable asyncronous). About the multiple sort, maybe we can add new prop to set Table comp to only perform single sort key. But I already add new property when we define table fields (sortable), so if we only want to sort single field, we just add sortable on the specific field, not all field (currently default value is FALSE) |
@@ -25,13 +25,23 @@ | |||
class="table-static__header" | |||
data-testid="table-static-header" | |||
:style="field.width ? { width: withUnit(field.width) } : {}" | |||
:class="field.thClass" | |||
:data-header="field.key"> | |||
:class="[field.thClass, { 'table-static__header--sortable': sortable && field.sortable }]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adenvt
Even if the sortable prop is provided when calling the Table component, but the field is not sortable, it will not be sorted.
}) | ||
|
||
async function sortField (field: TableField<T>) { | ||
if (!props.sortable || !field.sortable || field.sortable === undefined) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adenvt
I also added a check here, when the field is not sortable it will not be sorted
Add sortable on Table Static
#443