komarovalexander / ka-table

Lightweight MIT React Table component with Sorting, Filtering, Grouping, Virtualization, Editing and many more
http://ka-table.com
MIT License
788 stars 58 forks source link

Add extendedSort option #301

Closed komarovalexander closed 1 year ago

komarovalexander commented 1 year ago

241

extendedSort allows fully customize sort logic, as a result you can use any extended sorting library, to implements different sort cases, such as MultipleSorting and others..

      extendedSort={(data, columns) => {
        let sortedColumns = columns.filter(c => c.sortDirection);
        if (sortedColumns.length === 0){
          return data;
        }
        sortedColumns = orderBy(sortedColumns, ['sortIndex'], ['asc']);
        const iteratee = sortedColumns.map(c => c.key);
        const order = sortedColumns.map(c => c.sortDirection === SortDirection.Ascend ? 'asc' : 'desc');
        return orderBy(data, iteratee, order);
      }}
      sortingMode={SortingMode.MultipleTripleStateRemote}

demo: https://komarovalexander.github.io/ka-table/#/sorting-extended