Sorting data in report designer

I'm asked to change an existing report in the report designer.

The task is to change the order of the shown data.

I have to change in the designer, because the data source is also used for other reports and other sorting.

where can I find samples, videos or documentation, to help me to solve this.

Comments

  • edited November 2019

    In the report, there is a TableObject which got an event "ManualBuild" event, where some data is handled.

    It is these data I want in an other sort order.

    Is it possible to sort the data in the "Code" window of the report?

    DataSourceBase rowDataElever = Report.GetDataSource("Prøvedata.Elever");

    (I have embed a picture of the 'code' )

    https://photos.app.goo.gl/7EHtKPoSoEDpeEA99

  • Yes, you have to change the order in the code for ManualBuild. Row Table1.PrintRow(2) prints the second row and fills it with data. You can change the output order here.

  • Is there any samples showing how to change the sort order in the 'code'?

  • As I said earlier - there is no specific template. It depends on your report and your code. You can try to understand the code or ask a friend programmer to help you.

  • If I could code this in visualStudio it was no problem solving this problem.

    Now I have to do the sorting in FastReport Code window, where there are no help!

    I have googled to similar questions in your forum, but I can see that they also got no useful help.

    It looks like I have to change the order in the datasource before it get to FastReport - it's going to be on report one datasourse and no reuse of datasources!

  • Do you want to reorder the data in your DataSource?

    I thought you were talking about the order of your rows in the table. Alternatively, you can load all your data not into a table, but into a variable, sort by the method you need, and then fill it with your code.

    A simple way:

    Use a DataBand, make it like a table, and use data sorting in a DataBand.

  • What should i do if i change my design to my report?

  • I don't understand what you mean.

  • Hello!

    If you're using a DataBand, double-click it in the designer -> go to the Sort tab -> add the desired field and sort direction (Ascending / Descending). For a table-based design, it's most convenient to place a single-row table directly on the DataBand—then the DataBand's built-in sorting will work without any manual code.

    If the report must be built using `TableObject.ManualBuild` in the script, collect the `DataSourceBase` rows into a temporary `List<...>` (`ds.First(); while (ds.HasMoreRows) { ... ds.Next(); }`), sort the list using LINQ / `Sort(...)`, and then output the rows using `Table1.PrintRow(1);` Table1.PrintColumns();

This discussion has been closed.