Dynamic sorting

It is possible to use dynamic sorting in Stimulsoft reports. Dynamic sorting provides the ability to change the direction of sorting within a report. Data sorting can be performed on multiple data columns as well as on one data column. Set the component's Interaction.Sorting Enabled property to true and change the value of the Interaction.Sorting Column property to enable dynamic sorting by one column. The value of this property is the data column on which dynamic sorting is performed. Note that only one data column can be specified per component. Then select a component with dynamic sorting. Dynamic sorting is performed in the following directions: ascending and descending order. Each click on the component reverses its direction. Below is a report page with dynamic sorting.

If you need to sort by several columns at the same time, you can do so by pressing the control button. Consider the following example. Suppose you have a report that contains the names of categories and a list of products. Below is a report template.

When viewing the report without sorting, the data is retrieved sequentially from the data source. To enable dynamic sorting, you must select a component so that clicking it changes the direction of the sort. For this example, select the Text component in the Header band. And set the Interaction.Sorting Enabled property of both components to true. In the fields of the Interaction.Sorting Column property, specify the data columns by which to sort the data. In this case, the text component with the expression CategoryName would have the column {Products.Categories.CategoryName}, and the text component with the expression ProductName would have the column {Products.ProductName}. Creating a Report To sort data by multiple columns, you need to click a component with control buttons to change the direction of sorting. Below is a report page rendered with dynamic sorting by multiple columns.

As you can see from the figure above, when sorting by multiple columns, the data is sorted by the first column first. In this case the categories are sorted in ascending order. Then sort the data by the second column. In this case, the products are sorted in descending order, but within each category they are sorted in descending order. In other words, the product category "beverages" is sorted from Z to A, the category "seasonings" is sorted from Z to A, and so on. To disable sorting by multiple columns, you must release the Control key and click the component with dynamic sorting.