# CRM Listing Pagination

**URL:** <https://community.hubspot.com/t/crm-listing-pagination/68570>\
**Category:** CMS Development\
**Tags:** free, professional, starter, enterprise\
**Created:** [November 4, 2022, 11:09am UTC](https://community.hubspot.com/t/crm-listing-pagination/68570 "2022-11-04T11:09:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jun22](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jun22/32/34870_2.png) [@Jun22](https://community.hubspot.com/u/Jun22)\
**Post date:** [November 4, 2022, 11:09am UTC](https://community.hubspot.com/t/crm-listing-pagination/68570/1 "2022-11-04T11:09:13Z")

</div>

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 !

```lia-code-sample
{% 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>

```

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [November 10, 2022, 7:12pm UTC](https://community.hubspot.com/t/crm-listing-pagination/68570/2 "2022-11-10T19:12:19Z")

</div>

Hey, @Jun22 👋 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

---

<div class="post-metadata">

**Author:** ![Jun22](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jun22/32/34870_2.png) [@Jun22](https://community.hubspot.com/u/Jun22)\
**Post date:** [November 11, 2022, 4:33am UTC](https://community.hubspot.com/t/crm-listing-pagination/68570/3 "2022-11-11T04:33:53Z")

</div>

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