APEX interactive report aggregate cell font color
Here is how change style for APEX interactive report aggregate cell e.g when calculated value is negative.
On this solution I pass aggregate cell value using Ajax to database. Application process checks passed values and returns JSON witch cells have e.g. negative value.
Values are checked on database side because all possible number formats we can have on report. This is of course one extra call to database, but I find this is easier than try handle numbers on JavaScript.
First create application item for holding report number format.
Set Session State Protection to Restricted - May not be set from browser.
Create application computation for application item.
- Computation Point: On New Instance (new session)
- Computation Type: Static Assignment
Go edit your interactive report number colums. Place application item to Number / Date Format.
Create On Demand application process CHECK_IR_AGGR_VALUES
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| DECLARE l_arr APEX_APPLICATION_GLOBAL.vc_arr2; l_num NUMBER; BEGIN FOR i IN 1 .. APEX_APPLICATION.G_F01.COUNT LOOP BEGIN l_num := TO_NUMBER(APEX_APPLICATION.G_F01(i), :F39006_NUMBER_FORMAT); IF l_num IS NULL THEN l_arr(i) := NULL; ELSIF l_num < 0 THEN l_arr(i) := 'NEG' ; ELSE l_arr(i) := 'POS' ; END IF; EXCEPTION WHEN VALUE_ERROR THEN l_arr(i) := 'ERR' ; END; END LOOP; APEX_UTIL.JSON_FROM_STRING(APEX_UTIL.TABLE_TO_STRING(l_arr)); END; |
Create dynamic Action. Select Advanced
- Name: Format IR aggerate values
- Event: After Refresh
- Selection Type: Region
- Region: {select your report region}
- Condition: No Condition
- Action: Execute JavaScript code
- Fire On Page Load: True
-
Code:
12345678910111213141516171819202122232425262728293031323334353637
var
lArr=
new
Array()
,lTd=$(
"td.apexir_AGGREGATE_VALUE"
);
if
(lTd.length===0){
return
false
;
}
lTd.each(
function
(i){
var
lTmp=
new
Array();
lTmp=$(
this
).text().split(
':'
);
if
(lTmp.length>1){
lTmp.shift();
}
lArr.push(lTmp[0]);
});
$.ajax({
url:
"wwv_flow.show"
,
traditional:
true
,
dataType:
"json"
,
type:
"POST"
,
data:{
p_flow_id:
"&APP_ID."
,
p_flow_step_id:
"&APP_PAGE_ID."
,
p_instance:
"&APP_SESSION."
,
p_request:
"APPLICATION_PROCESS=CHECK_IR_AGGR_VALUES"
,
f01:lArr
},
success:
function
(jd){
$.each(jd.row,
function
(i,jr){
if
(jr.R===
"NEG"
){
lTd.eq(i).css({
"color"
:
"red"
});
}
if
(jr.R===
"POS"
){
lTd.eq(i).css({
"color"
:
"green"
});
}
});
}
});
- Selection Type: None
Create aggregate to your report from action menu. Now negative values are red and positive values are green.
No comments:
Post a Comment