You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is anyone able to help with an example of how to use the sortBy Action with a Data Table in React? I don't understand where I actually make the call to sortBy() with my header key.
Here is my render Prop:
constdataTableProp=({ rows, headers, getTableProps, getHeaderProps, getRowProps, getTableContainerProps, getSelectionProps, sortBy })=>(<TableContainertitle="Leases Parsed"// use Template Literal Strings to create an inline object to show the dynamic value.description={[`Found ${leasesToSelect.length} Leases`]}{...getTableContainerProps()}><Table{...getTableProps()}size='md'><TableHead><TableRow><thscope="col"/>{headers.map((header)=>(<TableHeaderkey={header.id}{...getHeaderProps({ header })}>{header.header}</TableHeader>))}</TableRow></TableHead><TableBody>{rows.map((row)=>(<TableRowkey={row.id}{...getRowProps({ row })}><TableSelectRowkey={'selectrow-'+row.id}{...getSelectionProps({ row })}// write it as below (as a function) instead of 'onChange={saveSelectedRow(row)}' so that a parameter can be passed that react will not choke on.onChange={()=>saveSelectedRow(row)}/>{row.cells.map((cell)=>(<TableCellkey={cell.id}>{cell.value}</TableCell>))}</TableRow>))}</TableBody></Table></TableContainer>);
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Is anyone able to help with an example of how to use the sortBy Action with a Data Table in React? I don't understand where I actually make the call to sortBy() with my header key.
Here is my render Prop:
Here is rendering of the Data Table:
Beta Was this translation helpful? Give feedback.
All reactions