Skip to main content
mollyn6512
November 14, 2022
Question

Add manual pagination to an interface

  • November 14, 2022
  • 10 replies
  • 1 view

Hi everyone,

I have an interface which displays a list of documents (UI_ListOfDocument), and originally user need to choose one document in the list to preview it (UI_Preview  will be displayed accordingly showing that chosen document's content), then click back to the list to choose another document for preview. 

The request is to create a pagination in the existing interface, so that user just needs to click the pagination buttons to see the next/ previous document preview. I already built the interface for the pagination, but was having trouble in linking the document to it to make it work. 

Currently, all related document from the data table are queried using a!queryEntity(), and are saved in a local variable, including it's content. 

If anyone has done this before, please leave an advise if possible. Thanks for your helps [emoticon:6d505171faa4497c85c5ca27290c555d]

    10 replies

    harshas2775
    Brainy
    November 14, 2022

    You need a local variable that stores the document id and then is used within UI_Preview. the local needs to be updated with document id on click of the pagination button. You can achieve it by indexing the variable that holds the list of documents. This, way whether user moves forward or backward you can set the appropriate value indexed from the variable storing all documents. 

    mollyn6512
    November 14, 2022

    Thanks for the explanation :) I got 1 more question: After clicking the button, I the document ID will be updated with the new document ID, which is the next one, but the ID are not increment in a row, but each case will have a set of random document ID. If If I sort the ID by order, how can I get the 2nd ID, then 3rd, 4th in the list every time I click the button? Can Index() do this function?

    harshas2775
    Brainy
    November 14, 2022

    yes index() can help you with this. you can make a index variable that stores the index as 1,2,3,4 etc for each data row in the document cdt. So upon pagination click you can increment the index variable to index +1 and using that get the next document details and id. e.g.  index(local!documentsCDT, local!index,{})

    mikes0011
    Brainy
    November 14, 2022

    Can you clarify why this requires Manual Pagination?  After reading your post a couple times I'm not even sure "pagination" is really quite what you're after.  To me it sounds more like you want a read-only grid listing a batch of queried documents-by-id, allowing the user to click a link to open one of them in a previewer, then adding "previous / next" links to the Previewer interface to allow the user to quickly browse among the existing list of doc IDs without having to click back up to the parent interface over and over again.  Am I far off?

    If I am pretty close: This is all pretty straightforward to implement, and it would be a lot easier to give you advice if you could attach some sample code for what you have so far, screenshots, and a detailed breakdown of what you're having trouble doing so far.  As usual, when providing sample code (of any length, but especially for anything longer than just a couple lines), please use the Code Box functionality found under the "insert" menu ("Insert" --> "Insert Code").

    IMHO this could all be built into a single interface pretty easily, though certain things could be simplified a bit by separating the "document preview with links" functionality into a child interface (that could be done afterwards though).

    The Expression Guru
    mollyn6512
    November 15, 2022

    Hi Mike, Harsha's above solution was absolutely what I need :D. And your assumption is correct by the way! Thanks for your time supporting :)

    mollyn6512
    November 15, 2022

    Btw, the pagination is an additional feature to existing interfaces, we already have the document list and doc preview interfaces, so there are less works need to be done than I thought :D