关闭对话框窗口后,将当前行的突出显示保存在Oracle Apex Classic Report中 [英] Saving the highlighting of current row in Oracle Apex Classic Report after closing the dialog window

查看:101
本文介绍了关闭对话框窗口后,将当前行的突出显示保存在Oracle Apex Classic Report中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家晚上好!

此刻,我正在使用Oracle Apex(4.2.6.00.03版)中的一页.它由两个经典报表组成-第一个是主"报表,第二个包含前者的详细信息".另外,还有几个按钮用于执行插入/更新/删除数据的操作.我的目的不仅是使操作生效,并从主"中选择行以刷新明细"报表(我已经完成了这些任务),而且还设法保存了报表行的突出显示,即使在执行操作(不仅刷新页面).

At this moment I'm working with one page in Oracle Apex (version 4.2.6.00.03). It consists of two Classic Reports — the first is a "master" one, and the second contains "details" of the former. Also there are several buttons for performing actions of inserting/updating/deleting the data. My purpose is not only to make the actions work and "details" report to refresh on choosing the row from the "master" one (I've completed these tasks), but also to manage to save the highlighting of reports' rows even after performing the actions (not only just refreshing the page).

现在,我将解释我已经完成的工作.可以通过我在每个报表的页脚中添加的脚本来选择行(并同时突出显示该行),它看起来像这样:

Now I'll explain what I've already done. One can choose the row (and simultaneously highlight it) by means of the script I put in every Report's footer and it looks like this:

<script>
$(".t20data","#master_report").live("click",function(){
  chooseMST($(this).find("span.MASTER").attr("id"));
});
</script>

master_report 是主"报告所在区域的ID,而 MASTER 则代表span类,其中我将所有单元格都包裹在报告中以保持行值ID.函数 chooseMST 是这样的:

There master_report is an ID of "master" report's region and MASTER stands for span class, in which I wrap all the cells in report to keep the value of row's ID. The function chooseMST is this:

function chooseMST(docID){
  $.post('wwv_flow.show',
         {'p_request'      : 'APPLICATION_PROCESS=SET_MASTER',
          'p_flow_id'      : $v('pFLowId'),
          'p_flow_step_id' : $v('pFlowStepId'),
          'p_instance'     : $v('pInstance'),
          'x01'            : docID},
         function(data){
          //refreshes "details" report
          $('#detail_report').trigger('apexrefresh');
          //deletes color from all the rows of "master" report
          $(".t20data","#master_report").parent("tr").children().css("background-color","#F2F2F5");
          //highlights the chosen row in "master" report
          $("#" + String(docID)).parent("td").parent("tr").children().css("background-color","#A3BED8");
         }
        );
}

动作(例如AJAX回调) SET_MASTER 是这样的:

The action (say, AJAX callback) SET_MASTER is this:

begin
  --clears the choice from "detail" report
  APEX_UTIL.SET_SESSION_STATE(P_NAME  => 'P400_DETAIL_RN'
                             ,P_VALUE => NULL);
  --makes the choice from "master" one
  APEX_UTIL.SET_SESSION_STATE(P_NAME  => 'P400_MASTER_RN'
                             ,P_VALUE => APEX_APPLICATION.G_X01);
end;

要刷新页面,我解决了清除隐藏项目 P400_DETAIL_RN P400_MASTER_RN 的问题,该过程位于此PL/SQL代码的标头之前:

To say about refreshing the page, I solved the problem of clearing the hidden items P400_DETAIL_RN and P400_MASTER_RN by having a process which goes before header with this PL/SQL code:

begin
  :P400_DETAIL_RN := APEX_UTIL.GET_NUMERIC_SESSION_STATE(P_ITEM  => 'P400_DETAIL_RN');
  :P400_MASTER_RN := APEX_UTIL.GET_NUMERIC_SESSION_STATE(P_ITEM  => 'P400_MASTER_RN');
end;

和Javascript函数 recolorRows ,该函数在每次加载页面时都会执行:

and the Javascript function recolorRows which is executed every time the page is loading:

function recolorRows(){
  $(".t20data","#master_report").parent("tr").children().css("background-color","#F2F2F5");
  if($("P400_MASTER_RN").val() != "") $("#" + String($("P400_MASTER_RN").val())).parent("td").parent("tr").children().css("background-color","#A3BED8");
  $(".t20data","#detail_report").parent("tr").children().css("background-color","#F2F2F5");
  if($("P400_DETAIL_RN").val() != "") $("#" + String($("P400_DETAIL_RN").val())).parent("td").parent("tr").children().css("background-color","#A3BED8");
}

有关详细信息"报告中的行的代码相似,因此让我省略此部分.对我来说,问题始于执行操作数据的动作.这是打开对话框窗口的功能,该对话框用于插入或更新在主"报告中选择的行:

The code concerning rows from "details" report is alike, so let me omit this part. Problems begin for me from performing the actions of manipulating the data. Here is the function which opens the dialog window for inserting or updating the row chosen in "master" report:

function MST_open(action){
  //the part of code which finds out with what parameteres we should call the dialog window
  $("#dialogFrame").attr("src",stringToCall);
  $("#dialogWindow").dialog({
    title:windowName,
    modal:true,
    width:500,
    height:500,
    resizable:true,
    close:reloadMST //the action on closing the window
  });
}

reloadMST 的代码如下:

function reloadMST(){
  $("master_report").trigger('apexrefresh');
  $("detail_report").trigger('apexrefresh');
}

在单击特定按钮(例如,更新")的对话框窗口中执行的Javascript函数是这样的:

And the Javascript function, which executes in the dialog window on the certain button click (for example, "Update"), is this:

function mstUpdate(){
  $.post('wwv_flow.show',
         {'p_request'      : 'APPLICATION_PROCESS=MASTER_UPDATE',
          'p_flow_id'      : $v('pFLowId'),
          'p_flow_step_id' : $v('pFlowStepId'),
          'p_instance'     : $v('pInstance'),
          'x01'            : apex.item("P402_SNAME").getValue()},
         function(data){
          //returns the ID of updated row in "msg" part of "res" variable
          var res = eval("(" + data + ")");
          if(res.status != "OK"){
            //the code which catches the error, if it appears
          } else {
            parent.MST_close(res.msg);
          }
         }
        );
}

其中 MST_close 是这样的:

function MST_close(docID){
  $("#dialogWindow").dialog("close");
  //see this function above
  chooseMST(docID);
}

因此,这是Javascript和PL/SQL操作的链,涉及主"报告中行的更新.插入/更新/删除数据的操作效果很好,但是对于保存行的颜色我不能说同样的话.当我仅选择行或刷新页面时,后者工作得很好,但是在执行例如更新之后,当前行将失去突出显示.通过调试(比方说,在Javascript代码中添加功能 console.log ),我发现名义上执行了一系列动作,这些动作必须导致保存突出显示内容,但看起来就像刷新报告一样变色或只是防止后者变色.

So, this is a chain of Javascript and PL/SQL actions, which concerns the updating of the row from "master" report. The actions of inserting/updating/deleting the data work great, but I can't say the same about the saving of rows' color. The latter works good while I'm only choosing rows or refresh the page, but after performing, for example, the updating, the current row loses its highlighting. By debugging (say, adding the function console.log in Javascript code) I found out that the chain of actions, which must lead to saving the highlighting, executes nominally, but it looks like refreshing the report either goes after coloring or just prevents the latter.

因此,我的问题是:即使在打开和关闭子对话框窗口之后,还有什么方法可以保存当前行的高亮显示?

Thus, my question is this: is there any way to save the highlight of the current row even after opening and closing the child dialog window?

推荐答案

我认为问题在于在模态窗口中更新记录的值后,您会刷新主页中2个报表中的数据,因此你失去了亮点.

I think that the problem is that after you update the value of a record in the modal window you refresh the data in the 2 reports in the main page and so you lose the highlight.

要解决此问题,请尝试在地区:您的经典报表上的事件刷新后上创建动态操作,该事件将执行javascript函数recolorRows().您也可以使用javascript.主要思想是,刷新2个报告(使用reloadMST()或其他方法)后,必须触发recolorRows().

To fix this try to create a Dynamic Action on the event After Refresh on Region: Your Classic Reports that will execute the javascript function recolorRows(). You can also do it with javascript. The main ideea is that after you refresh the 2 reports (using reloadMST() or other method) you must trigger recolorRows().

这篇关于关闭对话框窗口后,将当前行的突出显示保存在Oracle Apex Classic Report中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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