Using custom paging in Razor reports
This article describes how to configure the number of displayed items in the report. As an example, we will use a report that shows all the contractors.
Designer
In the Reports section of Designer, create a report on contractors that will show the contractor information, industry and responsible users. Select .NET Razor in the Report Layout unit on the Display Settings tab:
On the Report Layout (.NET Razor) tab, open the Template Wizard.
This window will open:
The template wizard will generate the markup.
Find the code fragment, responsible for display: DataTable items = data.Get(); - this value is set by default, it means that the standard number of items is used:
If instead of Get() you specify GetAll(), the page will display all the entries, regardless of the selected number.
To set a custom number of displayed entries, use the Controller Code on the Display Settings tab. Check the box Use User-Defined Controller Code. A new tab will appear:
On the Controller Code tab find the report parameters: var parameters = inputParams.Info.Parameters as Parameters;
Below add:
result.Model.CustomPagerParameters.AdditionalSizes.AddRange(new List<int>(){200, 300, 500});
result.Model.CustomPagerParameters.AdditionalSizes = result.Model.CustomPagerParameters.AdditionalSizes.Distinct().ToList();
var source = result.Model.DataSources["Data"];
As the result, you will be able to select 200, 300, 500:
If you need to display a specific number of items on a page, add these lines:
if (source.PagerSettings.ContextPageSize == 0)
source.PagerSettings.PageSize = 200;
The markup:
Let's display, for example, 7 entries: source.PagerSettings.PageSize = 7;
As the result, each page will display 7 entries.