How to select specific rows

SOLVE
Highlighted
Regular Contributor

Community,

 

My 100-row table contains 5 groups of 20 rows each, with column types: 'Red', 'Orange', 'Yelllow', Green', 'Blue'. I wish to display only the data from the 'Red' row on the Red page, 'Blue' rows on the Blue page, etc.

Beginning with this:

 

{% set table_id =<id> %}

{% for row in hubdb_table_rows(<id>) %}

 

How can I accomplish this filtering for each of the 5 pages?

 

Many thanks!

 

WmFlanigan

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
Highlighted
Solution
Regular Advisor

Hi @wmflan39,

 

Yes you can do that by below code, for ascending order

{% set queryparams = "color_name=Red&orderBy=sort_column_name" %}

for descending order add - sign before column name

{% set queryparams = "color_name=Red&orderBy=-sort_column_name" %}

We hope its work for you.

Did our post help answer your query? Help the community by marking it as a solution.

 

Thanks,

Team TRooInbound

View solution in original post

4 Replies 4
Highlighted
Regular Advisor

Hi @wmflan39,

 

you can add filter in hubdb_table_rows method, just like below code

{% set table_id =<id> %}
{% set queryparams = "color_name=Red" %}

{% for row in hubdb_table_rows(<id>, <queryparams>) %}

 

Hope its works for you

Team TRooInbound 🙂

 

Reply
0 Upvotes
Highlighted
Regular Contributor

TRooInbound,

Thank you so much! This solves the problem (I'm no hubl nerd).

Can I combine query parameters to a) select color_name=red AND sort by sort_number descending?

 

Thanks again,

 

WmF

Reply
0 Upvotes
Highlighted
Solution
Regular Advisor

Hi @wmflan39,

 

Yes you can do that by below code, for ascending order

{% set queryparams = "color_name=Red&orderBy=sort_column_name" %}

for descending order add - sign before column name

{% set queryparams = "color_name=Red&orderBy=-sort_column_name" %}

We hope its work for you.

Did our post help answer your query? Help the community by marking it as a solution.

 

Thanks,

Team TRooInbound

View solution in original post

Highlighted
Regular Contributor

Excellent, TRooInbound! Again, you have been very helpful.

 

WmF

Reply
0 Upvotes