How to achieve the ranks of exchange effect reports

Usually we design two-dimensional cross-tab report, the transverse and longitudinal dimensions dimensions are fixed, and users want and that can quickly convert horizontal and vertical dimensions according to their needs to view the report.

gif

As shown above, we click of a button or text, you can report the ranks of the dimensions of each conversion, such a dynamic transition effects to set how to achieve it?

Here I introduce two ways method:

1. The two reports hyperlinks

2. The report dynamic single judge

Two reports Hyperlinks

Realization of ideas:

Report ranks of two-dimensional cross-dimension, there are two cases, we only need to do two reports corresponding to the two cases, a button to switch hyperlinks to achieve, the goal is to connect another report.

Implementation:

1. Create a report, called the ranks of the converted file 1.rpx, data source comes under dry-run Designer demo data sources, data collection using SQL retrieval methods, SQL is:. SELECT Orders owner region, orders orders. the amount of the employee. surname + employees. employees FROM name as orders, orders WHERE employees. employee ID = employee employee ID.

2png

2. Set the report cells expression, Run Dry designer cells can be directly written expression, also supports drag and drop fields generated expressions.

Cell B1 we generated expression through dragging fields: the data set in the lower right corner of the panel design may just see our dataset and the new field, select the corresponding field, and then selecting a packet, to drag the field B1 cell,

Cell B1 appears = ds1.group (owner region; owner region);

8png

A2 B1 with cell operation, to select a different employee field drag, resulting expression is = ds1.group (employee; Employee: 1);

B2 cell selection order amount, select the summary, the summary way summed drag fields to cell B2, expressed as = ds1.sum (order amount).

9png

3. Modify cell expansion mode, the default extension direction is a longitudinal cells, select B1, extended mode is provided in the right panel property scale.

5png

4.A1 cells write directly on the ranks of the exchange, set the hyperlink expression: "./ showReport.jsp rpx = / 30 interactive reports / swap ranks 2.rpx?", Hyperlinks window: _self.

6png

5. Save the report as the current one, save the file named "the ranks of the converted 2.rpx", the A2 and B1 cell expression reversed, the A1 hyperlink expression changed to:? "./ showReport.jsp rpx = / 30 interactive reports / interchanging rows 1.rpx ".

After the above settings, we have completed the production of most of the brain does not burn Report ranks of two-dimensional exchange report, using showReport.jsp visit the ranks of conversion 1.rpx, click on the words that will convert the ranks to become the ranks of conversion 2.rpx , although the user clicks to switch, do not do conditional.

Single report dynamic judgment

Realization of ideas:

The current value of the flag FLAG to the value of his change is determined packet field transverse and longitudinal packet used according to this value.

Implementation

1. Save the ranks of the converted 1.rpx a report, called the ranks of the converted file .rpx.

2. The report adds a common parameter Change parameter name, an integer data type, a default parameter value;

Two dynamic parameters: Parameter name group1, string data type, value expression is if (change == 1, "the owner region", "employee";

Parameter name Group2, a string data type, value expression is if (change == 1, "employees", "the owner region").

7png

3. Modify Cell Expression

Longitudinal and transverse packet packet field value of the dynamic parameters by dynamically changes, modifications to the expression B1 = ds1.group ($ {group1}; $ {group1}: 1), to modify the expression A2 = ds1 .group ($ {group2}; $ {group2}: 1).

8png

4. Modify the ranks of exchange hyperlink expression

Hyperlinks expression is: "? ./ showReport.jsp rpx = / 30 interactive reports / interchanging rows .rpx & change =" + if (change == 1, -1,1)

9png

After the above settings, we convert .rpx by showReport.jsp access ranks in the browser address bar, enter the url:

http: // localhost: 6868 / demo / reportJsp / showReport.jsp rpx = / 30 interactive reports / ranks of the converted .rpx? access.

10png

When the ranks click on the table header into the text of the report or refresh the current report, but the parameter value change has become a -1, and the ranks of the group field has changed.

11png

Can be quickly achieved by two methods described above, the effect of exchange Report ranks, you do not want to do multiple reports to achieve, it is recommended to use the second method to achieve, if not used to determine the condition of the set, the first method can be used Although related to the two reports, just save your first report, a simple modification on the line, the workload can suddenly modify the law does not count, nor small curved around the second method, the specific choice of the appropriate method according to their own situation right .

Attached is two ways of reporting instances , convenient control article needs to achieve the ranks of exchange.

Published 48 original articles · won praise 13 · views 20000 +

Guess you like

Origin blog.csdn.net/zozoxxma/article/details/103761032