Detect cell header click in new table retool

Hi @victoria @Tess, @All
We have new table in retool, and we want to do server side sorting. So to do that we have two parameters, sortOrder(have asc or desc), and sortField(based on the column header selected) which can be passed in the API call. Now, the issue is we are unable to find click event for the column header as there are event handlers for selected row and cell, click and change cell, but nothing for column header click. So how to achieve that ?

Hi Shivam! The table's state exposes a sort property called sortArray that contains an array of your currently active sorts (we currently allow tables to be sorted by one column at a time). It contains the columnName and direction (asc or desc).

We have upcoming features that will further help with server-side sorting, so keep an eye out for those!

2 Likes

Hi @AnnaW
Thanks a lot :slight_smile: for the quick reply as I saw the reply on mail but writing now as I had multiple releases for couple of days and went on leave thereafter. The table's state sortArray has columnName and direction properties, which changes on clicking headers and re-clicking the same header(for asc and desc up and down arrows can be seen on the header cell). It's working as expected though it would be nice to see the upcoming features of server-side sorting as mentioned by you.
Thanks once again.

1 Like