Pagination

Certified Senior Developer

Hi,

I am trying to make an interface wherein I have a read only grid that displays data from a table stored in the database. Now I wrote an expression rule to fetch the data and passed it in the data parameter of the read only grid.

I want to implement pagination so that only 10 records initially are shown, clicking on the side arrow button '>' will load the next 10 records i.e. I will be running the query again and again for every 10 records changing my startIndex and batchSize. this will ensure that the query will not fail if the data is huge.

I wanted help in implementing the pagination as I tried implementing a few things and it didn't work. I'll attach what I have implemented.

PS : The pageSize parameter will not work, as the requirement is to "not use" pageSize. 

  

This is the expression rule where increment tells the batchSize, and times lets me tell the startIndex

This is the interface code

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Senior Developer
    in reply to Stefan Helzle

    The requirement was given I guess so that we find alternatives of page size,a

    Now about the datasubset, I might sound amateur, but wouldn't it put us in the same problem of putting load on the query ? Like I wanted only 10 records at a time  

  • 0
    Certified Lead Developer
    in reply to GautamShenoy

    Is this a test or a training?

    I do not understand your question about the datasubset. The gridfield will manage paging based on the additional values in the datasubset. When you only pass the data part of it, this will not work.

    I missed one important thing? In the initial post you write "it didn't work". What exactly did not work?

  • 0
    Certified Senior Developer
    in reply to Stefan Helzle

    It is a training.

    The task given was, I need to fetch data from the database in batch format. i.e. 10 rows at a time. Now initially I did the page size thing and it worked fine.

    But then 1 complexity added was to pass only 10 records at a time to the grid and not the entire data from the table. So the page size will not do my job here

    Onto the didn't work part, I tried passing 10 records, but then It did not show me the '>' key to move to next batch of records. I tried adjusting the records such that I get the '>' key, but then problem was, the '<' key was disabled. Now I can get the next 10 records, but I can't access the previous 10 records   

  • 0
    Certified Lead Developer
    in reply to GautamShenoy

    The grid uses the totalcount value from the datasubset to manage paging. You need to enable this.

    There is so much going wrong here ....

    Remove your manual startIndex calculation. The grid uses the paginginfo to tell the query how much data to fetch. Pass this into the expression and use it accordingly.

    This is a full example of a working paging grid fetching only 5 rows at a time.

    a!gridField(
      label: "Read-only Grid",
      labelPosition: "ABOVE",
      data: a!queryEntity(
        entity: cons!ADM_ENTITY_APPLICATIONS,
        fetchTotalCount: true,
        query: a!query(
          pagingInfo: fv!pagingInfo
        )
      ),
      pageSize: 5,
      columns: {
        a!gridColumn(
          label: "Name",
          sortField: "name",
          value: fv!row.name
        )
      },
    )