Skip to content

Example for table sorting #435

Answered by stefroussos
JoeVanGundy asked this question in Q&A
Discussion options

You must be logged in to vote

Have a look at https://github.com/glideapps/glide-data-grid/blob/main/packages/source/src/use-data-source.stories.tsx#L231

Assuming there aren't issues with the other props, something like this should work:

const sortArgs =  useColumnSort({
  columns: tableColumnsMap,
  getCellContent: getData,
  rows: tableData.length,
  sort: {
    column: tableColumnsMap[1],
    direction: 'desc',
    mode: 'smart',
  },
});

<DataEditor
  columns={tableColumnsMap}
  rows={tableData.length}
  {...sortArgs}
  width="100%"
  height="100%"
  onColumnResize={onColumnResize}
  overscrollX={50}
  overscrollY={50}
  keybindings={{ search: true }}
  getCellsForSelection={true} // Also missing this for search 
/>

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@bruceharrison1984
Comment options

Answer selected by jassmith
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants