The demo video has been posted to the Forum http://www.cognoschina.net/club/thread-10286-1-1.html
During the first report competition, JavaScript was used to sort the List Value fields. Although this is very practical, JavaScript supports different browsers with different kernels, in addition, developers who make reports may not be familiar with JavaScript, so although I think what I wrote is already very detailed, however, many netizens still encounter many problems during the use process and ask me how to debug Javascript. However, JavaScript is not clear in a few words. Then I suddenly thought that tracing could be used to sort the data? I tried it for one afternoon and finally got it. Later, I spent a month on other things, and I used the weekend to sort it out. Send to everyone
The sorting implementation idea is not mentioned here. For details, refer to the blog post I posted two days ago.
You can use your own tracing to sort the data, that is, the report's drilling object is its own. During the drilling process, the parameters are changed to sort the data.
The sorting example of any field list sent in the previous two days. Shows how to open the sorting list.
To be able to change parameters in tracing, we must create several more data items. We need five data items in ascending and descending order (up and down) and three columns (A, B, and C) to be sorted ). As shown in:
The data expression is the value to be received by the parameter. The up data item is 'up '.
Next, add the sorted image to the column header, click unlock, and place the image component in the "year" column header, as shown in:
Click the image, change the source type in the attribute column to "report expression", and set the expression content
If (paramvalue ('sorttype') = 'up ')
Then
('HTTP: // 127.0.0.1: 9300/p2pd/pat/images/sortstate_ascending.gif ')
Else
('HTTP: // 127.0.0.1: 9300/p2pd/pat/images/sortstate_descending.gif ')
This expression dynamically displays the Image Based on the passed parameters.
Next, create a tracing definition for the year. For ease of understanding, we define the name as up and select the target report
Click Edit to set the passed parameters
Select "pass data item value" as the method, and do not set the corresponding value for the parameter. Click OK.
We are copying the year, and the trace name is down. Change the value of the data item passed by sorttype to down.
When you run the report, you can see that there are two years in the year column. Click the previous one to sort by year in ascending order, and then click the next one to sort by year in descending order.
To avoid this problem, we need to use a conditional style to control the display.
Switch to the condition Resource Manager, create a Boolean variable ISUP, and set the expression
Paramvalue ('sorttype') = 'up'
Set the style variables of the two years to ISUP, and do not show when the previous year is "yes" (the box type is set to null ), if the last year is "no", it is not displayed.
When you run the report again, there is only one year. Click it to sort the report, and the picture shows whether the report is in ascending or descending order.
Go to the condition resource manager again and create a string variable sortcolumn. The expression is:
Paramvalue ('sortcolumn ')
Set three values: A, B, and C.
Select the image and set sortcolumn as the style variable. The image is displayed based on the parameter value. The year is used as an example. The corresponding parameter value is a. Therefore, the box type corresponding to B, C, and others must be set to null.
Now the sorting of a field is complete. copy and paste the three objects into the following columns, then you can set the trace passed value and the corresponding style respectively.
Shows the final effect.