Using Groupby filter on select column type in Hubdb

 <ul> 
 {% for group in hubdb_table_rows(dynamic_page_hubdb_table_id,"&orderBy=episode_number&orderBy=series_order")|groupby('series_name') %} 
 <li>
 <ul>
 {% for row in group.list %}
 {% if loop.first %}{{ row.series_name.name }} {% endif %}
 <li><a href="{{ request.path }}/{{ row.hs_path }}">{{ row.hs_name }} </a></li> 
 {% endfor %}
 </ul>
 </li>
 {% endfor %}
 </ul> 

Hi there, I want to groupby on a select column type in Hubdb, which it does, but it turns the whole group into a string. As a work around I just find the value on the first iteration of the loop. But I’d like to show the dropdown name with the {{group.grouper}} but that won’t work, and then also order the groups by the Order Id value in said select column. I found this to only work if you use a string or number fields, and do an orderby with the ‘OrderBy’ query attribute. I feel like I should be able to group by the dropdown name, and use the hubdb select order to order the groups? ‘series_name’ is the select column in my hubdb table. I removed the group.grouper, and replaced it with a for loop to show the select column ‘series_name.name’. Any help would greatly appreacated.

P.S. I’m using a dynamic table

Hey @torreyj

Thank you for sharing this. I’ll tag a few experts that can share their expertise.

Hey @piersg @Jake_Lett @DanielSanchez any tips you can share with @torreyj?

Thank you :slightly_smiling_face:

Sharon

@torreyj I think the problem is you didn’t specify which value to use from the “series_name” object. The select column type returns an `id` and a `name`. Try updating the groupby filter to use one of those instead:

|groupby('series_name.id')

UPDATE: after testing this myself the `|groupby(‘series_name’)` should work if it’s a single select column. You can also access the “series_name” object (name, id, etc) by using the `grouperObject` variable in the loop.