Add manual pagination to an interface

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 Smiley

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    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. 

  • 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?

  • 0
    Certified Lead Developer
    in reply to mollyn126

    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,{})

  • Sorry I didn't get your guidance here :(

    The list of document IDs was queried from a table, and is saved in local variable, below you can see that for the same case, there are different document ID:

    For example, I am choosing the 1st one: id = 2943356, if I click button next, I want the local!selectedDocumentId to be updated with Id = 2948520. 

    How can I do it by using index()?

  • 0
    Certified Lead Developer
    in reply to mollyn126

    I have mentioned the steps so that its more clear. Hope this clarifies.

    First declare a variable say

    local!arrayIndex:1,

    then, within the saveInto of pagination button add the line as

    a!save(local!arrayIndex,
        if(local!arrayIndex<length(local!dataSToreEntityVariable),
            local!arrayIndex+1,
            local!arrayIndex))
    
    
     

    just below the above code add the below line of code, to set the next document Id to the variable used to preview document. Thus, index increment and indexing the next row from the main variable happens on click of pagination button. 

    a!save(local!selectedDocumentId,
    index(local!dataStoreEntityVariable.id, local!arrayIndex,{}))

Reply
  • 0
    Certified Lead Developer
    in reply to mollyn126

    I have mentioned the steps so that its more clear. Hope this clarifies.

    First declare a variable say

    local!arrayIndex:1,

    then, within the saveInto of pagination button add the line as

    a!save(local!arrayIndex,
        if(local!arrayIndex<length(local!dataSToreEntityVariable),
            local!arrayIndex+1,
            local!arrayIndex))
    
    
     

    just below the above code add the below line of code, to set the next document Id to the variable used to preview document. Thus, index increment and indexing the next row from the main variable happens on click of pagination button. 

    a!save(local!selectedDocumentId,
    index(local!dataStoreEntityVariable.id, local!arrayIndex,{}))

Children