Use one download button to download csv files based form filters

  1. I have a list of applicants on a page that is filtered by 2 select fields ( Year of application and Role Applied for).
  2. I’d like to download the list of applicants based on the values of 2 filters of Year and Role above.
  3. I have successfully setup the normal download system with a direct query that gets applicants of particular role and it works fine. With just 3 roles now, I can create separate download systems and buttons for each role. But I’d want to make this dynamic to enable me to use just that one download button to download records based on the two filters.
  4. I added two variables (year_of_apply and role_applied to the GET global and set the WHERE clause equal to them. But it appears, it doesn’t work like the way it works with filtering records on a page.

How do I get this done please.

Hello and welcome :slight_smile:

How is the server connect structure?
Are you using a query to filter the results and using it to download the csv?

Yes. I am using a query to filter results and using it to download the csv which works. But not able to get it to change the query upon changing the values in the select field.


Upon changing the Role Applied for or the year, I’d like the contents of the file to be downloaded to change as the table shown on the page changes.

I don’t know if file download is working for you, but I’m having some troubles that I’ll report tomorrow…

In the meantime:
You can do this with another server action, that filter what you have on page = what the table is showing.

Maybe you can follow this, please sorry if I misunderstood your question.
I hope at least this can give you some idea :slight_smile:

I have a table called csv1 wich has roles and year fields:

image

Then I create server connect with two get inputs:

image

And a query with this condition:

What you see in red means that if there’s no value under $_GET.role/$_GET.year then all values are listed.
If some value is set, then it will filter the query.
If the year/role are required, just delete them.

If we preview the query:

image

image

Now I create a setvalue which contains a random number in this case an UUID

The reason I’m doing this is because I want an unique name for the csv file.

And the csv exports look like:

image
image


On the client side I have the server connect with no autoload:

image

And 2 selects:

image

image

I create a button that will call the server connect with dynamic event success:

As you can see both $_GET values are selected from both select input.
It can be the same select that filters your table that’s on your screenshot

So If I preview this:

And the files are created

image

Now I add the browser component:

image

And on the server connect I select success dynamic event:

image

And then I click on browser go to step and set the path where the created CSV is:

As you can see there’s a dynamic value there, which is the name of the csv file:

So the csv will be downloaded with the filtered results:

image

I hope this can help you !

Edit: If no data is available, no csv will be created, then it will throw an error as Data is empty, so you can use dynamic error event and display some message

1 Like