APEX 5.1 autorefresh Region with variable refresh time

女生的网名这么多〃 提交于 2019-12-11 04:52:56

问题


  • P998_SESS_INFO is my classic report
  • P998_REFRESH is hidden item
  • P998_REFRESH_RATE is LOV with static values of STATIC:
    • 10 Sekunden;10000,
    • 20 Sekunden;20000,
    • 30 Sekunden;30000

I define a dynamic action of type java script expression on change set value for P998_REFRESH:

$x('P998_REFRESH').value = $x('P998_REFRESH_RATE').value;

HTML Header:

<script type="text/javascript">
  var interval = `$`v("P998_REFRESH");
  // refresh every 10 seconds
  setInterval("jQuery('#P998_SESS_INFO').trigger('apexrefresh');", interval); 
</script>

but this will not work. Any suggestions available? Thank you


回答1:


Two problems:

1 - this code do not start the event change on item. (this change the value on the page, but not trigger the dynamic action). instead of this

$x('P998_REFRESH').value = $x('P998_REFRESH_RATE').value;

try this

$s('P998_REFRESH', $x('P998_REFRESH_RATE').value);

2 - you need to clear the previous setInterval value. it's not enough set new interval. So you need to store in a variable every call to setInterval

 var sintervalid = setInterval("jQuery('#P998_SESS_INFO').trigger('apexrefresh');", interval);

and to reset

clearInterval(sintervalid);
sintervalid = setInterval("jQuery('#P998_SESS_INFO').trigger('apexrefresh');", interval);

If I were to do something like this, I would try it like this:

1 - I create one global variable in my html header, setting the default value:

<script type="text/javascript">
  var sIntervalId = setInterval(function(){ 
                      jQuery('#P998_SESS_INFO').trigger('apexrefresh');
                    }, 30000);
</script>

2 - I create a dynamic action when change my item that store the interval

dynamic action: change item P998_REFRESH_RATE

true action: execute javascript code:

clearInterval(sIntervalId);
sIntervalId = setInterval(function(){ 
                          jQuery('#P998_SESS_INFO').trigger('apexrefresh');
                        }, $x('P998_REFRESH_RATE').value);

***I did not test this, but it would be more or less that way.



来源:https://stackoverflow.com/questions/49450968/apex-5-1-autorefresh-region-with-variable-refresh-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!