How do I turn off the Order Feature in a Table

I have a report table where all the columns have been thoughtfully ordered and they are exactly the way I like them.
I now realize that if the user wants to change the width, they could inadvertently change the order of a column making the table meaningless.
How I do I disable the order feature for the columns in a table?

Mike

Hi @mdsmith1,

There is currently no way to disable the order feature in a Retool table. However, there are a few workarounds that you can use:

  • Use a data source that returns the data in the desired order. This is the most reliable solution, as it ensures that the table will always be displayed in the correct order, regardless of what the user does.
  • Use a script to reset the order of the columns whenever the user changes the width of a column. This is a less reliable solution, as it is possible for the script to fail or for the user to find a way to bypass it.
  • Use a custom Retool component to create a table that does not support ordering. This is the most complex solution, but it is also the most flexible, as it allows you to customize the table to meet your specific needs.

Option 1: Use a data source that returns the data in the desired order.

To use this workaround, you would need to modify your data source to return the data in the order that you want it to be displayed in the table. You can do this by using a database query or by writing a custom script.

Once you have modified your data source, you would need to update your Retool table to use the new data source. To do this, open the table properties and select the new data source from the Data source drop-down menu.

Option 2: Use a script to reset the order of the columns whenever the user changes the width of a column.

To use this workaround, you would need to write a script that resets the order of the columns whenever the user changes the width of a column. You can add this script to the Table events section of the table properties.

Here is an example of a script that resets the order of the columns whenever the user changes the width of a column:

def reset_column_order():
    table = workflow.get_block("table")

    # Get the current order of the columns.
    column_order = table.get_column_order()

    # Reset the order of the columns to the desired order.
    table.set_column_order(column_order)

To add this script to the Table events section of the table properties, open the table properties and click the Add event button. In the Event field, select the Column width changed event. In the Script field, paste the script above.

Option 3: Use a custom Retool component to create a table that does not support ordering.

To use this workaround, you would need to create a custom Retool component that does not support ordering. This is a more complex solution, but it is also the most flexible, as it allows you to customize the table to meet your specific needs.

Here are some resources that can help you create a custom Retool component:

I hope this helps!

:grinning:

Patrick

Patrick:
Thank you for this writeup.
It will probably take me a while to figure this out.
In the meantime I am going to ask the Upgrade Team to look into this.
Thank again.

Mike

Sure! Succes!

:grinning:

Patrick