Highlight rows based on criteria [message #288088] |
Fri, 14 December 2007 14:27 |
spirillen
Messages: 3 Registered: December 2005 Location: Sacramanto, CA
|
Junior Member |
|
|
I'm trying to highlight several rows in a form (detail block shows 18 records at a time), based on the value in a field - i.e. if my_block.my_text_field='Y' then...make this row appear in red. I tried to use a post-query trigger with a visual attribute, but that doesn't work. I also tried manually setting the background_color for each field, using a cursor, but no luck there either.
I'm probably just missing something in the syntax, but I had a hard time finding enough information in Oracle help or online so I would appreciate any help I can get. (The one thing I did find was a reference from this forum about keeping a record highlighted after update, but it didn't work either.)
Thanks,
LK
current code:
PROCEDURE DISPUTE_DISPLAY IS
records_in_items number;
dispute number;
cur_itm VARCHAR2(80);
cur_block VARCHAR2(80) := :System.Cursor_Block;
BEGIN
first_record;
--this counts the records in the block:
select count(*) into records_in_items
from ledger.grant_ledgers
where decl_num=:disa.decl_num and
fips_num=:disa.fips_num;
first_record;
cur_itm := Get_Block_Property( cur_block, FIRST_ITEM );
for i in 1..records_in_items LOOP
--this criteria identifies if the row shoudl be red
select count(*) into dispute
from ledger.grant_payments
where request_id=:ledg.request_id and
dispute='Y';
if dispute>0 then
cur_itm := cur_block||'.'||cur_itm;
Set_Item_Instance_Property( cur_itm, CURRENT_RECORD,
VISUAL_ATTRIBUTE,'VISUAL_ATTRIBUTE_DISPUTE');
end if;
cur_itm := Get_Item_Property( cur_itm, NEXTITEM );
END LOOP;
END;
|
|
|
Re: Highlight rows based on criteria [message #288094 is a reply to message #288088] |
Fri, 14 December 2007 15:27 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
I'd say that you were close; at least, if I understood what you've said.
Here's an example: I have created a sample form based on Scott's 'EMP' table and decided to colour all 'sal' (salary) items to red if salary is less or equal 1500 / colour them green if salary is higher than 1500.
To do so, I have also created two visual attributes: 'va_red' (set background colour to red) and 'va_green'. Furthermore, I wrote the POST-QUERY trigger on a block level which looks like this:if :sal <= 1500 then
set_item_instance_property('sal', current_record, visual_attribute, 'va_red');
else
set_item_instance_property('sal', current_record, visual_attribute, 'va_green');
end if;
Note that I used the SET_ITEM_INSTANCE_PROPERTY built-in.
This is the result:
I hope you'll be able to fix your code now; basically, you don't need a LOOP at all, nor all that code you've written. A little tiny POST-QUERY might do the job.
[Updated on: Fri, 14 December 2007 15:28] Report message to a moderator
|
|
|
Re: Highlight rows based on criteria [message #288098 is a reply to message #288094] |
Fri, 14 December 2007 15:49 |
spirillen
Messages: 3 Registered: December 2005 Location: Sacramanto, CA
|
Junior Member |
|
|
Thank you! Thank you! Thank you!
I had to tweak it a little to make it work for my form, but that was the way to go - I just knew it had to be much easier than my approach.
Lene
|
|
|
Re: Highlight rows based on criteria [message #307494 is a reply to message #288098] |
Wed, 19 March 2008 00:38 |
thomasscaria
Messages: 21 Registered: July 2007 Location: Kuwait
|
Junior Member |
|
|
try this
DECLARE
cur_itm VARCHAR2(80);
cur_block VARCHAR2(80) := :System.Cursor_Block;
BEGIN
IF :fld6 = '1' THEN
cur_itm := Get_Block_Property( cur_block, FIRST_ITEM );
WHILE ( cur_itm IS NOT NULL ) LOOP
cur_itm := cur_block||'.'||cur_itm;
Display_Item( cur_itm, 'HILIGHT');
cur_itm := Get_Item_Property( cur_itm, NEXTITEM );
END LOOP;
ELSE
cur_itm := Get_Block_Property( cur_block, FIRST_ITEM );
WHILE ( cur_itm IS NOT NULL ) LOOP
cur_itm := cur_block||'.'||cur_itm;
Display_Item( cur_itm, 'NORMAL');
cur_itm := Get_Item_Property( cur_itm, NEXTITEM );
END LOOP;
END IF;
END;
|
|
|
|