Forum OpenACS Q&A: Re: listbuilder, groupby, orderby(s)

Collapse
Posted by Dave Bauer on
Here is what I did:

set group_by_values [list [list region { groupby region } [list orderby "region\ asc" ] ] ]
set groupby_orderby "region asc"
set order_by_list [list response_id [list  orderby_asc "${groupby_orderby}, res\ponse_id asc" orderby_desc "${groupby_orderby}, response_id asc"] \
        position    [list  orderby_asc "${groupby_orderby}, position asc" order\by_desc "${groupby_orderby}, position asc" ] \
        pretty_creation_date [list  orderby_asc "${groupby_orderby}, creation_d\ate asc" orderby_desc "${groupby_orderby}, creation_date asc"] \
                       region {orderby region}]

So to explain that, we only had one column to group on, so you can either group or not, in this case so its a little simpler. I dynamically build the orderby specification for each order by option to prepend the groupby column at the beginning of the orderby spec. This allows ordering by the group column, and also the orderby column.

I never did grasp all the ways to use group by, but maybe this example will help.

Collapse
Posted by Alexandre Simard on
Yes, I guess that's the only way to go, short of hacking template::list::orderby_clause to automatically prepend the groupby column, which I'll be doing soon enough.

Thanks, Dave! As far as I can tell, there's no other way to use groupby right now.