CRM Listing Pagination

Hello guys,
I have tried to setup a Pagination on my Deal Table listing module. Code below I was been able to run on the page but its query is “request.query_dict.page_num” will it work on the result of this line of code :

{% set company_deals = crm_associations(associated_companies.results[0].id, ‘HUBSPOT_DEFINED’, 6, “limit=10&offset=0&order=-createdate”, ‘dealname,amount,dealstage,createdate,closedate’) %}
Please help me how to replace the query variables to make it work on my table not a HUBDB table. how to set a query on it . Hoping someone can give me some tips. it would be awesome !

{% set batch_num = 10 %}

{% if not request.query_dict.page_num %}
 {% set page_num = 1 %}
 {% set offset_num = 0 %}
{% elif request.query_dict.page_num %}
 {% set page_num = request.query_dict.page_num %}
 {% set offset_num = page_num|add(-1) * batch_num %}
{% endif %}

{% set query = "limit=" ~ batch_num ~ "&offset=" ~ offset_num %}

{% set rows = hubdb_table_rows('5493634', query) %}

<ul class="item-list">
 {% for row in rows %}`
 <li class="list-item">{{ row.name }}</li>
 {% endfor %}
</ul>

{% set nav = hubdb_table_rows('5493634') %}

{% set total_pages = nav|length|divide(batch_num) %}

{% set more_pages = total_pages - page_num %}

<nav>
 {% if page_num > 1 %}
 <a class="previous-posts-link" href="{{ content.absolute_url }}?page_num={{ page_num|add(-1) }}" title="Next">Next</a>
 {% endif %}

 {% if more_pages == 0 %}
 {% if page_num|add(-4) >= 1 -%} <a href="{{ content.absolute_url }}?page_num={{ page_num|add(-4) }}">{{ page_num|add(-4) }}</a>{%- endif %}
 {% endif %}

 {% if more_pages <= 1 %}
 {% if page_num|add(-3) >= 1 %}<a href="{{ content.absolute_url }}?page_num={{ page_num|add(-3) }}">{{ page_num|add(-3) }}</a>{% endif %}
 {% endif %}

 {% if page_num|add(-2) >= 1 %} <a href="{{ content.absolute_url }}?page_num={{ page_num|add(-2) }}">{{ page_num|add(-2) }}</a>{% endif %}

 {% if page_num|add(-1) >= 1 %}<a href="{{ content.absolute_url }}?page_num={{ page_num|add(-1) }}">{{ page_num|add(-1) }}</a>{% endif %}

 <a class="active" href="{{ content.absolute_url }}?page_num={{ page_num }}">{{ page_num }}</a>

 {% if page_num|add(1) <= total_pages %}<a href="{{ content.absolute_url }}?page_num={{ page_num|add(1) }}">{{ page_num|add(1) }}</a>{% endif %}

 {% if page_num|add(2) <= total_pages %}<a href="{{ content.absolute_url }}?page_num={{ page_num|add(2) }}">{{ page_num|add(2) }}</a>{% endif %}

 {% if page_num <= 2 %}
 {% if page_num|add(3) <= total_pages %}<a href="{{ content.absolute_url }}?page_num={{ page_num|add(3) }}">{{ page_num|add(3) }}</a>{% endif %}=
 {% endif %}

 {% if page_num == 1 %}=
 {% if page_num|add(4) <= total_pages %}<a href="{{ content.absolute_url }}?page_num={{ page_num|add(4) }}">{{ page_num|add(4) }}</a>{% endif %}
 {% endif %}

 {% if total_pages > page_num %}
 <a class="next-posts-link" href="{{ content.absolute_url }}?page_num={{ page_num|add(1) }}" title="Older Posts">Previous</a>
 {% endif %}
</nav>

Hey, @Jun22 :waving_hand: A few questions:

  • Have you made any progress here?
  • Is the above example your table code?
  • Can you break out a specific example showing what works in HubDB but not in your table?

This helps the community better understand where and if they can assist with your project.

Best,

Jaycee

Hey Jaycee,
I already made a progress I made a custom pagination via javascript insteads.
Thanks