CMS Development

wmflan39
Contributor

How to select specific rows

SOLVE

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

0 Upvotes
1 Accepted solution
TRooInbound
Solution
Key Advisor

How to select specific rows

SOLVE

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
TRooInbound
Key Advisor

How to select specific rows

SOLVE

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 🙂

 

0 Upvotes
wmflan39
Contributor

How to select specific rows

SOLVE

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

0 Upvotes
TRooInbound
Solution
Key Advisor

How to select specific rows

SOLVE

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

wmflan39
Contributor

How to select specific rows

SOLVE

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

 

WmF

0 Upvotes