Create Dynamic Links to Group the Same Table View BY ANY COLUMN!

Table views (and a few other types) have a ‘Group by’ option, to group rows by a certain column.

But if you wanted to view the same set of rows with a different grouping, you have to create a new view for each ‘Group by’ setting. Or do you? :face_with_monocle:


I noticed ‘&group=’ in the URL of one of my views, followed by percent signs and other parameters (URL encoding).

The decoded format looks like this:
&group=[{"Column":"county_name","Order":"Ascending"}]

So if you replace county_name with the column name you want to group by, and ENCODEURL() the new string, you can add that to the end of a LINKTOVIEW(TableView).

I added a new table with one row for every column name, then pass that value to an action.

This allows for using a single table view and a single action to dynamically navigate to a table view that is grouped by any column!

I have added this functionality to my US States public sample app.

https://www.appsheet.com/samples/Sample-app-with-US-zip-codes?appGuidString=d6ab1dec-d053-4920-9c74-fc205df266d0

15 Likes

Probably should ENCODEURL() the [ColumnName] too. I try to avoid spaces and special characters in column names so things like that aren’t an issue. But I think it would be a problem with the wrong column names.

2 Likes

Man you’re on a roll!

1 Like

Sometimes I can’t get this stuff out of my head until I post it lol. :joy:

This one, in particular, was screaming at me while I was trying to work today.
:brain: :loudspeaker: “THE PEOPLE MUST KNOW OF THIS DISCOVERY!”

4 Likes

Do these kind of link hacks work on mobile as well?

Yes. I just confirmed on mobile using the sample app.

2 Likes

Nice!
The link is fun to play with… All sorts of interesting nuggets in there.

1 Like

Great tips thank you!

I belive you managed to simplify the tips previously introduced by Appsheet team

4 Likes

This behavior would also somewhat explain why it was (a while ago) setting a group by on a view and then switching to a different view type that didn’t have grouping setup on the front-end editor would be what I called “sticky grouped”.

1 Like

Thank you @GreenFlux
Deep Links are really a key to much more things in AppSheet.
I was thinking about opening a new Post to collect all Deep Link Tips…

2 Likes

Yeah, I was thinking about a post listing all the optional URL parameters, like &group=,&at=NOW()+1, &quickedit=true, etc. I can add those to your post if you want to start a new tread for it. :grinning:

2 Likes

So cool. If you like you can start the post and I can contribute :slight_smile:

2 Likes

Ok, I started a list of Deep Links and URL parameters. It could use some examples for LINKTOFILTEREDVIEW() or maybe linking to another app.

1 Like

If you want to group by multiple columns at once (for drill-down grouping), the syntax is like this:

& "&group="
& ENCODEURL( '[
    {"Column":#col1#,"Order":"Ascending"} ,
    {"Column":#col2#,"Order":"Ascending"} ,
    ...
]' 
3 Likes