问题
P998_SESS_INFO
is my classic reportP998_REFRESH
is hidden itemP998_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