Server Side Pagination - Using the built in paging controls

Posted by: joshuadmatthews on 20 July 2023, 12:24 am EST

    • Post Options:
    • Link

    Posted 20 July 2023, 12:24 am EST

    I have implemented pagination by binding parameters to the query, so the user can change the current page and page size and the dataset refreshes.

    I was hoping I wouldn’t have to bind my own parameters as the paging parameters of the report viewer are already exposed to expressions, but it seems these built in paging control don’t trigger a dataset refresh when they are modified, which makes sense for client side paging.

    It would be cool if there was a way to tell it to refresh the datasource when using the built in paging controls so enable using them for server side paging. Is there any way I could hook in an accomplish this currently?

  • Posted 20 July 2023, 12:38 am EST

    Another good option might be if I could put a paging controls into my report and use the Update Parameter action to drive the paging parameters from within. This seems like it would be a bit difficult though using the controls that currently support interactive actions.

  • Posted 20 July 2023, 2:31 am EST

    I was able to figure out how to wire up page controls within the report using Update Parameter actions.

    I would like to allow the user to use the PageNumber parameter from the parameters panel, as I don’t think I can embed a drop down list in the report. This is difficult because I can’t set parameter values with an expression.

    In my case I have a totalCount coming from the api, and I setup a calced columnusing that and page size to display the number of pages.

    Unfortunately parameters can either be driven by a dataset of pages, which I don’t have, or the user can define parameter values and drive each one from an expression. It would be beneficial if we could drive the entire set of values from an expression so I could explode 4 pages into 1, 2, 3, 4 values to select from.

  • Posted 23 July 2023, 10:07 am EST

    Hi Joshua,

    You can load your report in code as a JSON Resource and then add default parameter values through code. Please refer to the following lines of code:

    MyReportJson.ReportParameters: [
        {
          "DataType": "String",
          "DefaultValue": { "Values": ["1", "2", "3"] }, //Add Values here
          "Name": "Parameter1",
          "Prompt": "Parameter1",
          "ValidValues": { "OrderBy": { "Condition": "None" } }
        }
      ]
    

    or you can load the report definition from the designer by using the getReport() method of the designer and add parameter values to the validValues.ParameterValues collection before passing the report to the Viewer:

    reportInfo.definition.ReportParameters[0].ValidValues.ParameterValues[]
    

    For more information please refer to the following pages of our documentation:

  • Posted 23 July 2023, 10:43 am EST

    The number of pages is dependent on the page size which the user can select, and the number of total records that are returned at runtime, so I can’t provide this to the report externally.

    I have an expression that gives me the number of pages using the mentioned data

    {Truncate([users_aggregate.aggregate.count] / @PageSize) + 1}

    This works as expected and I use it to show total number of pages in my report.

    Just seems to be no way to use this to drive the set of parameter values available for @PageNumber parameter.

  • Posted 24 July 2023, 7:27 pm EST

    Hi Joshua,

    Unfortunately, it is not possible to add multiple default values to the parameter with an expression. You would either have to use a DataSet that returns the required values or just add the values manually.

    I would suggest you to create a simple API that returns 1-n values based on a parameter(n). You can then use your expression “{Truncate([users_aggregate.aggregate.count] / @PageSize) + 1}” to pass to the dataset as a parameter.

    This way you can have PageNumber values in Parameter for the report.

  • Posted 24 July 2023, 11:36 pm EST

    I tried this approach, but no success. The issue is that users_aggregate.aggregate.count is a result of the first dataset, and it doesn’t seem like there is any way to drive a parameter value off of the result of a dataset. The query for the pages would have to wait until the first dataset loads before it can execute.

  • Posted 26 July 2023, 3:19 am EST

    Hi Joshua,

    Please try to add the Expression to Calculated Fields section of the Dataset. I have attached a sample report for reference.

    If the issue persists then, please share a sample report so we can run your report at our end and provide you with a solution optimal for your use case.PageNumberReport.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels