SAP/ui5-webcomponents-react

AnalyticalTable: Can't cancel `onSort` event

Closed this issue · 2 comments

ej612 commented

Describe the bug

Hi there!

We want to add sorting functionality to our AnalyticalTable, but we'll be doing the sorting in the backend. Meaning we want the UI to look like it normally would, but we don't want the table to actually do any sorting of its own. Instead, we'll swap out the table rows we'll be giving to it.

My first instinct was to set sortable=true and to implement onSort like this:

onSort={(event) => {
  event.preventDefault();
}

However, that doesn't seem to have any effect, the table still sorts on its own. Is this a bug or am I doing it wrong?

Thanks a lot in advance!

Isolated Example

https://stackblitz.com/edit/github-9ssrdb?file=src%2FApp.tsx

UI5 Web Components for React Version

1.29

UI5 Web Components Version

1.24

Browser

Chrome

Hi @ej612

you can use the manualSortBy reactTableOption to disable the internal sorting logic.

https://stackblitz.com/edit/github-9ssrdb-gkgbzg?file=src%2FApp.tsx

ej612 commented

This is exactly what I need, thank you @Lukas742!