Skip to content
Source
Sign inSign up
TanStack/table

Sorting help #40

ClosedSamSimmons(GitHub profile, opens in a new tab) opened this issue 2 comments

Hey, I'm having some trouble implementing custom sorting. Say I have a component

const BigTable = (props) => {
  let { data } = props
  return (
    <ReactTable
      data={data}
      columns={columns}
    />
  )
}

If I had an age column, that was a string, and I wanted to use a function like (a, b) => parseInt(a) - parseInt(b) to sort the data. From the docs I've been trying to set the table to manual use onSortingChange, but I can't figure out how to use it properly. Any chance you could point me in the right direction?

  1. If you want to fully control the sorting algorithm, you will need to treat the table as a server side setup. See https://react-table.js.org/?selectedKind=2.%20Demos&selectedStory=Server-side%20Data&full=0&down=0&left=1&panelRight=0&downPanel=kadirahq%2Fstorybook-addon-actions%2Factions-panel

    I may possibly make the sorting customizable more easily On Wed, Jan 25, 2017 at 12:45 AM Sam Simmons <notifications@github.com> wrote:

    Hey, I'm having some trouble implementing custom sorting. Say I have a component

    const BigTable = (props) => { let { data } = props return ( ) }

    If I had an age column, that was a string, and I wanted to use a function like (a, b) => parseInt(a) - parseInt(b) to sort the data. From the docs I've been trying to set the table to manual use onSortingChange, but I can't figure out how to use it properly. Any chance you could point me in the right direction?

    — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <https://github.com/tannerlinsley/react-table/issues/40>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AFUmCZjWbsLFoe0ofBgmscFQFtTzNbH9ks5rVv2AgaJpZM4LtL83> .

  2. Any update regarding customizing the search? I have a getter that shows some date as a formatted string, but I want the sorting to be done by the actual date value..

Sign in to join this conversation.