Home » Developer & Programmer » Application Express, ORDS & MOD_PLSQL » Conditionally Setting background color in apex (4.1.0.00.32)
Conditionally Setting background color in apex [message #611176] |
Fri, 28 March 2014 17:07 |
|
tejaabbaraju
Messages: 2 Registered: March 2014
|
Junior Member |
|
|
I have a following table.
CREATE TABLE pavan_teja
(
id INTEGER NOT NULL
,record_type VARCHAR2 (10 BYTE) NOT NULL
,mbr_first_name VARCHAR2 (50 BYTE) NOT NULL
,mbr_last_name VARCHAR2 (50 BYTE) NOT NULL
,mbr_id VARCHAR2 (10 BYTE)
,csr_amt NUMBER (18, 4)
,rating_area VARCHAR2 (5 BYTE)
);
1. id is unique
2. record_type will have values CMS, FAC only
3. mbr_id will be always same for both CMS, FAC records
Example Data:
ID RECORD_TYPE MBR_FIRST_NAME MBR_LAST_NAME MBR_ID CSR_AMT RATING_AREA
1 CMS SHARON CABERLY 0000046669 32.64 014
2 FAC SHARON CAVERLY 0000046669 32.64 14
3 CMS JACK PARROTTE 0000158332 0 014
4 FAC JACK PARROTT 0000158332 2 14
5 CMS DELORES LORANZO 0000179553 0 012
6 FAC DELORES LOZANO 0000179553 1 12
Now, in the apex application I want to hightlight the columns that are not same between CMS and FAC records by comparing them using MBR_ID which will be always same for consecutive records.
I do not want to highlight the entire record. I want to highlight only the columns that are not same in the records where the MBR_ID is same.
Please help me!!!
[Updated on: Fri, 28 March 2014 17:07] Report message to a moderator
|
|
|
Re: Conditionally Setting background color in apex [message #611189 is a reply to message #611176] |
Sat, 29 March 2014 03:56 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Unfortunately, built-in Apex formatting tool can't do that (at least, I don't know how to do it). Therefore, I had to write my own code. Here's how.
First, with some help of the LAG analytic function, I calculated value of the previous record's value for every column - it is the "WITH TEST AS" with factoring clause. If you aren't familiar with it, run the query in SQL*Plus (or any other tool you use to access an Oracle database), just to see what it does.
Its result is "input" for Interactive Report's final query which then - in CASE - compares value of current and previous values. If they are different, I'm painting them red.
with test as
(
select
id,
record_type,
mbr_first_name,
lag(mbr_First_name) over (partition by mbr_id order by record_type) prev_mbr_first_name,
mbr_last_name,
lag(mbr_last_name) over (partition by mbr_id order by record_type) prev_mbr_last_name,
csr_amt,
lag(csr_amt) over (partition by mbr_id order by record_type) prev_csr_amt,
rating_area,
lag(rating_area) over (partition by mbr_id order by record_type) prev_rating_area
from pavan_teja
)
select
id,
record_type,
case when mbr_first_name <> prev_mbr_first_name then
'<font color="red">'|| mbr_first_name ||'</font>'
else mbr_first_name
end mbr_first_name,
--
case when mbr_last_name <> prev_mbr_last_name then
'<font color="red">'|| mbr_last_name ||'</font>'
else mbr_last_name
end mbr_last_name,
--
case when csr_amt <> prev_csr_amt then
'<font color="red">'|| csr_amt ||'</font>'
else to_char(csr_amt)
end csr_amt,
--
case when rating_area <> prev_rating_area then
'<font color="red">'|| rating_area ||'</font>'
else rating_area
end rating_area
from test
order by id, record_type;
Under "Report Attributes" tab, you have to set all those columns type to "Standard Report Column" otherwise you'll get rubbish instead of red coloured text (but you can try it, just to see how it looks like).
The final result is:
|
|
|
|
|
Goto Forum:
Current Time: Thu Dec 12 07:22:06 CST 2024
|