如何从Oracle APEX 4 Classic Report中选择行元素值(表标记中的行元素) [英] How to select a row element value from Oracle APEX 4 Classic Report (row element from a table tags)

查看:242
本文介绍了如何从Oracle APEX 4 Classic Report中选择行元素值(表标记中的行元素)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是挑战..

我在Oracle APEX 4中有一个基于SQL 1区域的经典报告

I have a classic report based on SQL on Region 1 in Oracle APEX 4

报告(Report1)的结构类似于

The report (Report1) is structured like

    DATE_COL(this column will be hidden) or even the whole region can be hidden)
Row1    12-01-2001
Row2    11-01-2001
Row3    10-01-2001

我想选择Row1的DATE_COL值,即Date1,并将其分配给ITEM的标签,该标签可以位于同一页面或另一页面上。

I want to select the value of DATE_COL of Row1 which is Date1 and assigned that to a label of an ITEM which can be on the same page or another page..

例如,ITEM说是P_ITEM,其名称将在屏幕上显示为12-01-2001

The ITEM say for example is P_ITEM whose name will be displayed as 12-01-2001 on the screen

所以,基本上我想选择DATE_COL列的报告的Row1元素并将其用作标签名称

So, essentially I want to select a Row1 element of report of column DATE_COL and use that as label name

然后我想选择DATE_COL的Row2元素,它是DATE2并分配给报告2在同一页面上的另一份报告的col1标签,看起来像这样

Then I wan to select Row2 element of the DATE_COL which is DATE2 and assigned to the col1 label of another report on the same page which is Report2 and will look like this

 <a href = "www.google.com"> 11-01-2001 </a> (this name is coming from report 1 of DATE_COL of Row2 element) also it has link

Row1   100
Row2   200

请指导我如何完成这个。

Please guide me how to accomplish this one.

示例html看起来像这样

The example html looks like this

<!DOCTYPE html>
<html>
<body>

<table id="report_R124146326020103259" cellspacing="1" cellpadding="0" border="1" summary="">
<tbody>

<tr>

<td>

<table class="report-standard" cellspacing="1" cellpadding="2" border="0" summary="">

<tbody>

<tr>
 <th id="DATE1" class="header" align="left">DATE1</th>
 <th id="DATE2" class="header" align="left">DATE2</th>
 <th id="DATE3" class="header" align="left">DATE3</th>
 <th id="DATE4" class="header" align="left">DATE4</th>
 <th id="DATE5" class="header" align="left">DATE5</th>
</tr>

<tr class="highlight-row">
 <td class="data" headers="DATE1">12-01-2001</td>
 <td class="data" headers="DATE2">11-01-2001</td>
 <td class="data" headers="DATE3">10-01-2001</td>
 <td class="data" headers="DATE4">09-01-2001</td>
 <td class="data" headers="DATE5">08-01-2001</td>
</tr>

<tr class="highlight-row">
 <td class="data" headers="DATE1">10-01-2001</td>
 <td class="data" headers="DATE2">09-01-2001</td>
 <td class="data" headers="DATE3">08-01-2001</td>
 <td class="data" headers="DATE4">12-01-2001</td>
 <td class="data" headers="DATE5">11-01-2001</td>
</tr>

</tbody>

</table>

</td>

</tr>

</tbody>

</table>

</body>
</html>

我想JQuery可以用来完成但不确定选择器需要如何使用。

I guess JQuery can be used to accomplish, but not sure, how the selector need to use.

谢谢,
--CP

Thanks, --CP

编辑1

我根据Tom的Jquery选择器创建了以下脚本,它确实选择了行元素。但是我在W3Schools html编辑器中运行的以下脚本没有选择我放入Test函数的row元素。我在A tag中调用的测试函数没有产生任何结果。然而,WelcomeMessage的另一个函数确实产生了结果。有人可以帮我识别错误吗?

I created following script based on Tom's Jquery selector which does selects the row element. However the following script which I ran in W3Schools html editor didn't select the row element, which I put in Test function. The test function which I am calling in "A tag" didn't produce any results. However the other function which is WelcomeMessage did produce the result. Can anybody help me identify the error?

<!DOCTYPE html>
<html>

<head>

    <script type="text/javascript" src="jquery.js"></script>

    <script type="text/javascript"> 
    function test(i) { 
       var ab = $("#report_DT tr:eq(i) td.data[headers='DATE1']").text();
       document.write(ab);
    }

    function welcomeMessage()
    {
      document.write("Welcome to Henley's Department Store!");
    }
    </script>

    </head>


    <body>

    <table id="report_DT" cellspacing="1" cellpadding="0" border="1" summary="">
    <tbody>

    <tr>

    <td>

    <table class="report-standard" cellspacing="1" cellpadding="2" border="0" summary="">

    <tbody>

    <tr>
     <th id="DATE1" class="header" align="left">DATE1</th>
     <th id="DATE2" class="header" align="left">DATE2</th>
     <th id="DATE3" class="header" align="left">DATE3</th>
     <th id="DATE4" class="header" align="left">DATE4</th>
     <th id="DATE5" class="header" align="left">DATE5</th>
    </tr>

    <tr class="highlight-row">
     <td class="data" headers="DATE1">12-01-2001</td>
     <td class="data" headers="DATE2">11-01-2001</td>
     <td class="data" headers="DATE3">10-01-2001</td>
     <td class="data" headers="DATE4">09-01-2001</td>
     <td class="data" headers="DATE5">08-01-2001</td>
    </tr>

    <tr class="highlight-row">
     <td class="data" headers="DATE1">10-01-2001</td>
     <td class="data" headers="DATE2">09-01-2001</td>
     <td class="data" headers="DATE3">08-01-2001</td>
     <td class="data" headers="DATE4">12-01-2001</td>
     <td class="data" headers="DATE5">11-01-2001</td>
    </tr>

    </tbody>

    </table>

    </td>

    </tr>

    </tbody>

    </table>

    <a href ="default.asp">  

    <div> <Script Language="JavaScript">
                         test(i);
                      </Script>
                 </div>


    </a>


    <a href ="default.asp">  

    <div> <Script Language="JavaScript">
                         welcomeMessage();
                      </Script>
                 </div>


    </a>
    </body>
    </html>

有人能发现错误,为什么测试功能没有检索到所需的结果?

Can anybody spot the error why test function is not retrieving the desired result?

推荐答案

理想情况下,您希望为您的区域分配一个静态ID(编辑区域>属性>静态ID)

Ideally you want to assign your region a static id (edit region > attributes > static id)

然后使用

$("#yourregionid tr:eq("+ rownumber_you_need +") td.data[headers='"+ header_id +"']").text()

请注意:eq使用了基于零索引的系统,因此第0行将是带有标题的系统,第1行是第1行的实际数据。
将header_id替换为您需要数据的列的标题。在你的例子中:

Take note that :eq uses a zero-index based system, so row 0 would be the one with the headers, and row 1 your first row with actual data. Replace header_id with the header of the column you need data from. In your example:

$("#yourregionid tr:eq(1) td.data[headers='DATE1']").text()
$("#yourregionid tr:eq(2) td.data[headers='DATE2']").text()

编辑:

<a href="javascript:test(1);">click for a test</a>
<script type="text/javascript"> 
function test(i) { 
   var ab = $("#report_DT tr:eq(i) td.data[headers='DATE1']").text();
   alert(ab);
}; 
</script>

编辑2:
因此,如果您想积极操纵第二份报告的表格标题:
- 为报表区域分配静态区域ID 2
- 为区域(您的第二个区域)的After refresh事件创建动态操作。这是必要的,以允许您的区域分页,同时仍保持更改的标题。
- 对于真实操作,请选择执行javascript代码:

Edit 2: So if you want to actively manipulate the table headers for your second report: - assign a static region id to your report region 2 - create a dynamic action for the "After refresh" event, for a region (your second region). This is necessary to allow pagination on your region while still maintaining the altered headers. - for true action, select an execute javascript code:

$("#report2staticid th").each(function(index){
   var linktext, newlink;
   if(index==0){
      linktext = $("report1staticid tr:eq(1) td.data[headers='DATE1']").text();
      newlink = $("<a />").attr("href", "www.google.com").text(linktext);
   } else if(index==1){
      //something for header 2
   } else if(index==2){
      //andsoforth
   };
   $(this).html(newlink);
});

这会循环第二个报告中的每个TH元素,并更改每个元素的html内容:我们在每一个中添加一个新的A标签。

This loops over each TH element in your second report, and changes the html content of each th: we put a new A-tag in each one.

编辑3:
您在实施中犯了一些错误:

Edit 3: You made some mistakes in your implementation:

function test(i) { 
   var ab = $("#report_DT tr:eq(i) td.data[headers='DATE1']").text();
   document.write(ab);
}

应该是

function test(i) { 
   var ab = $("#report_DT table.report-standard tr:eq("+i+") td.data[headers='DATE1']").text();
   document.write(ab);
}

我是一个输入参数,你需要将它连接到选择器字符串。

i is an input parameter, and you need to concatenate it into the selector string.

您的HTML脚本标记也是错误的。你打电话给测试并提供我。什么是我?它没有定义。提供价值。 (请记住,这是rownumber。)

Your HTML script tag is also wrong. You call test and provide "i" to it. What is "i"? Nowhere is it defined. Provide a value. (Remember, this is the rownumber.)

<Script Language="JavaScript">test(1);</Script>

完整代码:

<!DOCTYPE html>
<html>
   <head>
      <script type="text/javascript" src="jquery.js"></script>
      <script type="text/javascript">
      function test(i) {
         var ab = $("#report_DT table.report-standard tr:eq("+i+") td.data[headers='DATE1']").text();
        document.write(ab);
      }
      function welcomeMessage()     {
      document.write("Welcome to Henley's Department Store!");
      }
      </script>
      <title></title>
   </head>
   <body>
      <table id="report_DT" cellspacing="1" cellpadding="0" border="1" summary="">
         <tbody>
            <tr>
               <td>
                  <table class="report-standard" cellspacing="1" cellpadding="2" border=
                  "0" summary="">
                     <tbody>
                        <tr>
                           <th id="DATE1" class="header" align="left">
                              DATE1
                           </th>
                           <th id="DATE2" class="header" align="left">
                              DATE2
                           </th>
                           <th id="DATE3" class="header" align="left">
                              DATE3
                           </th>
                           <th id="DATE4" class="header" align="left">
                              DATE4
                           </th>
                           <th id="DATE5" class="header" align="left">
                              DATE5
                           </th>
                        </tr>
                        <tr class="highlight-row">
                           <td class="data" headers="DATE1">
                              12-01-2001
                           </td>
                           <td class="data" headers="DATE2">
                              11-01-2001
                           </td>
                           <td class="data" headers="DATE3">
                              10-01-2001
                           </td>
                           <td class="data" headers="DATE4">
                              09-01-2001
                           </td>
                           <td class="data" headers="DATE5">
                              08-01-2001
                           </td>
                        </tr>
                        <tr class="highlight-row">
                           <td class="data" headers="DATE1">
                              10-01-2001
                           </td>
                           <td class="data" headers="DATE2">
                              09-01-2001
                           </td>
                           <td class="data" headers="DATE3">
                              08-01-2001
                           </td>
                           <td class="data" headers="DATE4">
                              12-01-2001
                           </td>
                           <td class="data" headers="DATE5">
                              11-01-2001
                           </td>
                        </tr>
                     </tbody>
                  </table>
               </td>
            </tr>
         </tbody>
      </table><a href="default.asp">
      <div>
         <script language="JavaScript" type="text/javascript">
         test(1);
         </script>
      </div>
      </a>
      <a href="default.asp">
      <div>
         <script language="JavaScript" type="text/javascript">
         welcomeMessage();                       
         </script>
      </div>
      </a>
   </body>
</html>

这篇关于如何从Oracle APEX 4 Classic Report中选择行元素值(表标记中的行元素)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆