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

Report real-time display time

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Reports, in addition to relatively statically showing summary statistics, distribution, trends and other data content, can also be used to display time-related real-time information, including real-time display time. For example, in the following device monitoring application system, the home page not only displays real-time monitoring data, but also needs to display real-time time in the upper right corner:

In fact, this form of "dynamic report" can be seen everywhere in our lives, and the most common one is the train timetable on the big screen of the railway station, which shows the current time, so that passengers can know at a glance how long their train will run and when the waiting train will arrive.

In fact, to achieve the above effect in the report is very simple, the basic idea is to let the page timing (for example, every second) call the JS method, in JS through the cell's ID to get the display time of the grid, the current time as the new value of this grid display on it.

Next, let's take a specific look at how to achieve such a common dynamic display time effect by drying the report.

1. Set the report cell expression

The first figure above is based on the report "equipment failure Analysis. RPX" that comes with the report designer. Next, we will use this report as an example. We first add time to our own report, merge N4 and O4 cells, and set the cell expression = string (now (), "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy

2. Set the JSP page tag

Then we open the report presentation page showReport.jsp and set the tag attribute generateCellId in this page so that the report cell generates the ID of the grid on the page.

When we open the original report display page, we find that the cell that sets the current time does not generate a corresponding ID, as shown in the following figure:

In order to get the cell through ID in the JS script, so that the value of the cell can be modified, we need to add the tag attribute generateCellId= "yes" to the displayed page, as shown in the following figure:

After setting this property, we can see on the page that the cell generates the corresponding id value:

3. Set the page JS method

Next, we add the JS method myrefresh () that dynamically changes the cell value in the page displayed in the report, in which the display time in the cell is dynamically changed through the ID of the cell, and the function myrefresh is called after 1 second through setTimeout (). Since the setTimeout () function will only be called once, we also need to add this function to the body of the myrefresh () function to achieve the effect of circular invocation. Here is the specific JS method:

Function myrefresh ()

{

Var tbl = document.getElementById ("report1_N12")

Var myDate = new Date ()

TBL [XSS _ clean] = myDate.toLocaleString ()

SetTimeout ('myrefresh ()', 1000)

}

SetTimeout ('myrefresh ()', 1000)

4. Preview the page effect

. In this way, after the above simple settings, we can display the "equipment failure analysis .rpx" report on the showReport.jsp page, and see the real-time change time at the top of the page. The page effect is as follows:

Through this simple example, we know that, as mentioned at the beginning, the report can not only present fixed statistical summary data, but also has a pretty good dynamic display ability. The way we use the regular call JS to change the value of the cell here can realize the dynamic change of the local content of the page, and there is no flicker refresh, no sense of violation!

What do you think? are you surprised? Are you surprised? Let's roll up our sleeves and use the report to enrich the data.

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