How to create table with pagination

Hi Experts,

How to create table with pagination. I have one employee table with bulk records and i want show the records in table with pagination functionality . Kindly give me some reference code.

1 Like

There are several ways of doing it and it all depends on what you’re trying to do and the stack you’re using etc.

The easiest way is if you use soy for generating the table and then have a rest end point that can fetch the data.

If you have a rest end point defined as /my-fetcher/{page number} . Then the initial page number would be 0. Then just increase the page number for each call and call the same javascript function to fetch the contents.

I usually retrieve the number of records that I want on a page + one more. That way I can look for the existence for the one more to determine if I should show a next button. In the json the server that is returned back, I would have the structure be something like:

{
    "results":[],
    "hasNext": true
}

Where results has the array of items for the soy template to render (i java something like theList.subList(0, endPos)) and hasNext is something like ( theList.size()>maxNumItems) ).

1 Like

Hi Daniel,

Is there any aui widget available like above issue table for pagination? So i can use available code or library easily or I have to implement pagination functionality with my table.

Hi Daniel,
I read your post and was like reading Fermat’s Last Theorem :confused:…I’m relatively rookie on Jira Development and this is my environment:

  • Atlassian SDK : 6.3.4
  • AMPS v: 6.36
  • Velocity Templates.

And these are my questions:

  1. If I’m using velocity, can I use Soy? Right now I’m generating the table with a call on a Java file that returns a JSON, then I create the table with JavaScript.
  2. What’s a Rest End Point and how to use it?
  3. Can you share some code as example?

Thanks in advance.