TreeTable: Custom sorting (for example from an API) needs better docs
Describe the bug
Hi, I'm using onSort function to make an API call for sorting, but when onSort function is used, original icon highlight and toggling between ASC and DESC is lost.
Expected:
- Highlight icon showing up
- Click on arrows toggling the state between ASC and DESC (0 and 1)
Actual:
- No indicator of sort being enabled
- sortOrder in event is always 1
Reproducer
https://stackblitz.com/edit/vqw5gi-vnizjy?file=src%2FApp.jsx
PrimeReact version
9.5.0
React version
17.x
Language
TypeScript
Build / Runtime
Create React App (CRA)
Duplicate of #6115 which has a reproducer so subscribe to that ticket please.
@melloware I have checked the other ticket - it's not the same issue. This one is about table-level "onSort" prop, the other one is column-level "sortFunction", and the behavior problem is different.
I'll try to put together a reproductor example ASAP. Thanks!
ok if you add a reproducer i can re-open this one.
@melloware Added reproductor and more details to description of the issue! Thank you.
@melloware Hello! Can you assign me please ?
@SpajicM The TreeTable works fine, you just need to manually connect the states to the TreeTable using the 'sortOrder' and 'sortField' properties:
@KirilCycle oh, thanks! Is this documented anywhere or I've missed it?
TreeTable's main page only explains sortable and sortMode props, while API page for sortOrder says: "Order to sort the data by default.", which sounds like it's only for setting prefered initial order, not that it should be used in combination with onSort function.
@KirilCycle oh, thanks! Is this documented anywhere or I've missed it?
Well, I didn't see it in the documentation, only descriptions of specific props
I noticed that vueprime TreeTable doesn't need to pass options manually, I think we should modify the current TreeTable to have similar behaviour, as even props description says that 'sortField' and 'sortOrder' should be used at initial render