Live Chat

We'll need to share your messages (and your email address if you're logged in) with our live chat provider, Drift. Here's their privacy policy.

If you don't want to do this, you can email us instead at contact@anvil.works.

Searching and Sorting in Data Grids

Are you new here?

Anvil is a tool for building full-stack web apps with nothing but Python and a drag-and-drop designer. Learn more on our website, or sign up and try it yourself -- it's free!

Data Grids are a great way to display tabulated data.

As with most things in Anvil, the behaviour of search and sort functionality is defined using Python (either in the browser or on the server).

Searching

To search, you can add a TextBox and a Button for the user to enter search queries. The Data Grid Searching tutorial that shows how to add a search widget to your Data Grid.

Animation showing searching in a Data Grid

Sorting

To sort, you can add a Link component to each column header and configure its click handler to run a sort function. Clone this app for an example:

Click here to clone the example app in the Anvil designer.

Here is the app running live.

Animation showing sorting Data Grid columns