Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The Strategy of FineReport hierarchical report to solve the problem of big data Collection display

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

In this paper, taking the filling report as an example, the problem of big data collection display is solved by pagination.

The idea is to filter part of the database data in SQL so that the browser can display the report page reasonably. (data segmentation, sentence I use MYSQL here, if you want to use other databases, please see the FineReport help documentation)

Step 1: open the fenye.cpt file.

The template interface is as follows

Two ds, and part of the data, and a hidden line.

Hide a line as follows

The function of the data here will be discussed below.

The contents of the ds1 are as follows

Statement content SELECT * from aaa limit ${f}, ${p}

The goal is to start with the ${f} hop and select the ${p} data (this $p is the number of pages shown, and the calculation of $f can be calculated as follows ($page-1) * the offset of the limit of $pmam MySQL starts at 0).

In the template parameters, I set their default values

$Please 20

$page=1

This is the same as the global parameters, the data cannot be seen when the template is previewed, and the parameters must be passed in through url only when the page is displayed.

The contents of the ds2 are as follows

This statement is relatively simple is to calculate the total number of data divided by the number of pages per page, you can get the total number of pages.

Report body

The first row of data is the previous page, the next page, the total number of pages and the current page, as well as a /, which is used to display the previous page and the next page in the toolbar, which is normally not shown here, so we block it (hidden) first. The rest is the display of user data.

What else do we need to do in order to show that the report can be the same as our normal report?

Here you need to write code to achieve the effect of the above picture.

Click on the gear to fill in the preview

You can see that we use seven custom buttons and a load end event here.

The code to load the end event is as follows:

Var toolbar = contentPane.toolbar

Var items = toolbar.options.items

Var customButton=items [2]; / / JQUERY takes the button on our toolbar. Items [2] represents the third button, which is displayed as a text box button.

Var inner = customButton.$table

Var btnWrapper = $("em", inner)

BtnWrapper.html ("")

/ / modify the properties of this button to change it to a text type, centered, and the icon was edited last time the mouse was held.

Var cellValue = contentPane.curLGP.getCellValue ("D1"); / / gets that the value of the D1 cell is page, the current page.

Var $input = $("input", btnWrapper)

$input.val (cellValue); / / copy to this text control, using the JQUERY method, you can COPY.

Var total=contentPane.curLGP.getCellValue ("C1")

If (total > parseInt (total)) {total=parseInt (total) + 1

}

ContentPane.toolbar.options.items [4] .setText (total)

/ / display the total number of pages on the fifth control, because this value may be a decimal, so determine whether or not to add a processing.

ContentPane.toolbar.options.items [3] .setText (contentPane.curLGP.getCellValue ("E1"))

Write a slash on the fourth control.

7 custom buttons:

The first home page:

The code is as follows:

_ window.location.href= "${servletURL}? reportlet=fenye.cpt&op=write&page=1"; / / Link to the fenye.cpt,page parameter = 1, which represents the first page.

The second previous page:

The code is as follows:

Var page= $("tr [tridx=0]", "div.content-container") .children () .eq (0) .html (); / / fetch the contents of the first cell in the first row.

If (page==0)

{

This.setEnable (false)

Alert ("Page is outside the specified range")

}

Else

_ window.location.href= "${servletURL}? reportlet=fenye.cpt&op=write&page=" + page// jumps normally if it is not less than 1, otherwise the display page exceeds the specified range and this control setting cannot be used.

The third current page that you can jump to:

Var toolbar = contentPane.toolbar

Var items = toolbar.options.items

Var customButton=items [2]

Var inner = customButton.$table

Var btnWrapper = $("em", inner)

Var $input = $("input", btnWrapper)

/ / fetch this control

$input.blur (function () {

Var toolbar = contentPane.toolbar

Var items = toolbar.options.items

Var customButton=items [2]

Var inner = customButton.$table

Var btnWrapper = $("em", inner)

Var $input = $("input", btnWrapper)

Var page=$input.val ()

Var total=$ ("tr [tridx=0]", "div.content-container"). Children (). Eq (2). Html ()

If (total > parseInt (total)) {total=parseInt (total) + 1

}

If (parseInt (page) > parseInt (total) | | parseInt (page)

< parseInt(1) ) { alert("你输出的页数不再指定范围内"); } else _window.location.href="${servletURL}?reportlet=fenye.cpt&op=write&page="+page }); //失去焦点后输入的值是不是在指定的范围内,如果在跳转到指定页面,就在else后面的URL,否则输出你的输出页面不对提示。失去焦点代表就是点击其他地方或者点击TAB键。 第四个斜线: 这个在加载时间里处理了。这边不需要处理。 第五个总页数: 这个在加载时间里处理了。这边不需要处理。 第六个下一页: var page= $("tr[tridx=0]","div.content-container").children().eq(1).html(); var total=$("tr[tridx=0]","div.content-container").children().eq(2).html(); //JQURUY取下一页和总页数 if (total>

ParseInt (total)) {total=parseInt (total) + 1

}

/ / determine whether the total number of pages is an integer, not plus one

If (parseInt (page) > parseInt (total))

{

This.setEnable (false)

Alert ("number of pages out of range")

}

Else

_ window.location.href= "${servletURL}? reportlet=fenye.cpt&op=write&page=" + page

/ / if the next page is in this range, jump there.

This control is not available, the output is incorrect.

The seventh last page:

The code is as follows:

Var total=$ ("tr [tridx=0]", "div.content-container"). Children (). Eq (2). Html ()

/ / take the total number of pages.

If (total > parseInt (total)) {total=parseInt (total) + 1

}

_ window.location.href= "${servletURL}? reportlet=fenye.cpt&op=write&page=" + total

/ / determine whether the total number of pages is an integer, not plus one, and jump to the last page.

The name of the display control needs to be added to the alias

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report