关闭对话框窗口后,在Oracle Apex Classic Report中保存当前行的突出显示

大家晚上好!

此时我正在使用Oracle Apex中的一个页面(版本4.2.6.00.03)。 它由两个经典报告组成 – 第一个是“主”报告,第二个包含前者的“细节”。 还有几个按钮用于执行插入/更新/删除数据的动作。 我的目的不仅是让行动起作用,而且“细节”报告在选择“主”行(我已完成这些任务)时刷新,还要设法保存报告行的突出显示。执行操作(不仅仅是刷新页面)。

现在我将解释我已经做过的事情。 可以通过我在每个Report的页脚中放入的脚本来选择行(并同时突出显示它),它看起来像这样:

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

master_report是“master”报告区域的ID, MASTER表示span类,其中我将报告中的所有单元格包装起来以保留行ID的值。 函数chooseMST是这样的:

 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是这样的:

 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_RNP400_MASTER_RN的问题,方法是在此PL / SQL代码的头之前进行:

 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

 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"); } 

关于“详细信息”报告中的行的代码是相似的,所以让我省略这一部分。 从执行操作数据的操作开始出现问题。 这是打开对话框窗口的function,用于插入或更新在“主”报告中选择的行:

 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函数是:

 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 ),我发现必须导致保存突出显示的操作链在名义上执行,但看起来刷新报告要么着色要么只是阻止后者。

因此,我的问题是:即使在打开和关闭子对话窗口后,有没有办法保存当前行的突出显示?

我认为问题在于,在模态窗口中更新记录的值后,您将刷新主页面中2个报告中的数据,因此您将失去突出显示。

要解决此问题,请尝试在区域刷新后的事件上创建动态操作 将执行javascript函数recolorRows() 经典报告 。 你也可以用javascript做到这一点。 主要的想法是刷新2个报告后(使用reloadMST()或其他方法),你必须触发recolorRows()

谢谢你,Cristian_I,非常感谢。 我最近解决了我的问题。 我的错误是我没有在HTML代码中完成隐藏的项目绑定 – 换句话说,仅通过Javascript。 看着隐藏项的行为,我发现当我试图在jQuery函数$(“#hidden_​​item”)。val()的帮助下找到它们的值时,我得到了之前的值,但不是当前的值(即会话状态值)。 所以这就是我突出不稳定的原因。

除了在刷新报告后立即触发动态操作之外,我应该在“着色”代码本身之前将这些字符串添加到我的函数chooseMST

 $("#P400_MASTER_RN").val(docID); //binding to exact string 

 $("#P400_DETAIL_RN").val(""); //clearing the choice in the "details" report. 

因此,重新着色行的问题刚刚消失! 因此,现在我的页面非常出色:突出显示是稳定的,甚至新行在插入后立即突出显示。