TanStackT
TanStack3y ago
1 reply
verbal-lime

How to enable multisorting for server side filtering?

Hey,
I use react-table v8 and sort my data at server side. It works great for one column, but my server can sort by multiple columns. What's the best way to achieve the multiSort-ft with manualSorting: true

  const table = useReactTable({
    data,
    state: { sorting: sortState, columnFilters: filters },
    manualSorting: true,
    enableMultiSort: true,
    manualFiltering: true,
    columns: tableColumns,
    getCoreRowModel: getCoreRowModel(),
    getExpandedRowModel: getExpandedRowModel(),
    onSortingChange: (sorting) => {
      if (onSort) {
        console.log(sorting()); // sorting() returns just on column, even if I hold down shift
        onSort(sorting());
      }
    },
    onColumnFiltersChange: (filterFn) => {
      if (onFilter) {
        onFilter(filterFn(filters));
      }
    },
    getRowCanExpand,
  });


Thanks and best regards!
Was this page helpful?