Let's say we have the task: to sort the matrix on the first page in the desired order, remember this order and apply for similar matrices on other pages.

This may be needed when you have several pages in the report that display matrices that are identical in headings, but which contain different data. For example, the first matrix displays the number of products sold, and the second displays the sales amounts by product. We need to sort by quantity or amount, and then apply the same order for the second matrix. This case is quite common in analytical reports.

Let's see it in practice. Let's take a completely hypothetical fruit sales statistics. However, only the types of fruits are not enough, there will be a list of fruit importing countries. The number of sold goods will be displayed for three years.

Table structure:

- country_name
- fruit_type
- year
- amount
- price
- sum

Standard sorting mechanisms will not help us here. Therefore, we will sort the number of fruits sold for each country. Let's outline a sequence of steps:

1. To get a list of countries.

2. For each country:

2.1. to get the values of cells with types of fruits and the number of products sold for each year;

2.2. to sort the values for the desired year;

2.3. for each row to fill the cells of fruits and the number for all years according to the indices of the rows in the sorted list.

The first column is the country, and this is ok for us, which means that we will sort the cells of the remaining columns. We first need to remember them, so that we can arrange them in the desired order according to the sorting plan. We will select one of the columns with data for a specific year and sort it in descending or ascending order. Then we will use the resulting index order to sort all the cells by column.

Let's get started. The matrix has an event for modifying an already constructed object - ModifyResult. Let's create a handler for this event in the report script.

Now we copy the report page with the matrix, but instead of the amount field we will output sum.

We will select the handler we have created for ModifyResult in the matrix events.

After running the report, we will see that the order of the fruit types on the two pages is the same. This means that the sorting on the first page is applied to the second page.

Thus, using the report script, we can manipulate the data in the matrices, as we want. The most important thing is to apply the same sort order on different pages of the report.

Fast Reports

- 800-985-8986 (English, US)
- +4930568373928 (German)
- +55 19 98147-8148 (Portuguese)
- info@fast-report.com
- 901 N Pitt Str #325 Alexandria VA 22314

Products

Company

© 1998-2024 Fast Reports Inc.