Sorting Supabase table views in WeWeb frontend

G’day mates,

So I’m hoping this is just a simple dumb thing I’ve missed, but I cannot for the life of me automate the sort order for a view of a table in WeWeb. I have a view of a table with two parameters setup, column name and sort order. The goal is when I click on the column header on the front end, it changes the column name to the clicked on column, and then will toggle between asc and desc.

So in the view, I have the parameters, and I have them hooked up to the sort function. The column name works perfectly. I can dynamically change that. However, I can’t get the sort order to trigger. The only way I’ve got that working is if Unbind it and manually change it. Now, I COULD set up two views one with sort order hard coded to desc and one to asc, and then switch between the views on the front end depending on which sort order is needed.

But obviously that’s not how it’s SUPPOSED to work.

I’ve tried text parameters, inputting asc, Asc, ASC. I’ve tried bools, I’ve even tried setting it as a number and 1, 0, -1. None of those work.

I can’t find any documentation that says what the sort function is supposed to take in to change it. It just says “choose the order” Views | Documentation

Or simply that you have a sort functionality per here: Supabase actions reference | Documentation

So I’m at a loss. If anyone can point out the hopefully super obvious step I’m missing, I’d greatly appreciate it.

Hey @Dan_OOT :waving_hand:
Can you show us what your workflow looks like on the column header?

Sure, I’m not sure it’s relevant at this point as I can’t even get it to work when using the test fields for the parameters on the table itself, but here’s the call that the workflow makes to the table. Each header clicked sends a hard-coded column header name, though I did turn it into a formula to try sending it in “” to make sure it went through as text.

This is what I get back from running the Action (IDs truncated for posting here):

{
“tableViewId”: “511e…”,
“parameters”: {
“7706…”: “invoice_number”,
“cab5…”: “Desc”
}
}

However, after running it, I don’t see the parameters updated on the table.

Regardless, that’s another issue because I can’t even get sort order functioning when editing the parameters here:

And confirming that they do actually update the parameters and are feeding the information into the formulas for the sort function. Verified that changing the column name works and as I said earlier, if I unbind the sort order and manually change between asc/desc I can adjust the sort order correctly.

I’ve installed an instance of Supabase to test on my project.
Using the values “DESC” or “ASC” on a value of a sort worked for me. If anything else is typed, it would default to asc order.
Did you also check the network tab in DevTool to see what’s in the payload of the request?

sigh I was pretty sure I’d tried all caps. But now it works. So that solved it. “ASC” and “DESC” are the text values that need to be fed into the sort function for it to work.