komarovalexander / ka-table

Lightweight MIT React Table component with Sorting, Filtering, Grouping, Virtualization, Editing and many more

Home Page:http://ka-table.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Visualise the initial sort state, and disable sort for specific columns

olliejm opened this issue · comments

commented

When I click on a column to sort it, an arrow appears indicating the sort direction.

I'm missing a way to ensure that this arrow is present initially when a sort is pre-applied, there doesn't appear to be any sortable, sorted or sortDirection or similar props on the Column type to provide information about the initial state, before the table is interacted with. My remote data query however has a default sort, and it would be ideal if I could reflect that in the UI

Just FYI I'm using SortingMode.SingleRemote.

I'm also not sure how to disable sorting on a specific column - I have some columns which should not be sortable within a table of otherwise sortable columns. I saw this comment suggesting not to dispatch the props change, but that seems to completely prevent all sorting from the point that the non-sortable column is interacted with onwards.

“I'm also not sure how to disable sorting on a specific column - I have some columns which should not be sortable within a table of otherwise sortable columns. I saw #162 (comment) suggesting not to dispatch the props change, but that seems to completely prevent all sorting from the point that the non-sortable column is interacted with onwards.”

I think the best way is to add one more property to column ‘isSortable’ - I can do it later, probably this week.

but for now you can wrap the reducer https://ka-table.com/docs_reducer.html#toc2

or prevent the headerCell onClick using the childComponents

commented

Thanks. I missed the sortDirection somehow

column.isSortable was added in v7.6.0
details here: https://github.com/komarovalexander/ka-table/releases/tag/7.6.0