Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2000
  • Last Modified:

Highlighting a Record based on criteria

Right now I have some criteria that will change the background color of an Item within a record.  But right now it will change the color of all the items, no matter what record it is.

Here is what I need to do - I have 3 records displayed (with a scrollbar if more items exist) in a column style.  Meaning that record 1 is column 1, and record 2 is column 2, etc.  Right now I find if A>B then change the background color of Field1.  This will change the color of Field1 in all the records:

SET_ITEM_PROPERTY('Field1', VISUAL_ATTRIBUTE, 'BACKGROUND_YELLOW');

I would like to change the color of all the items in Record1, but not in Record2.  Can this be done?  and if so can someone get me started on the right track?
0
Intern
Asked:
Intern
  • 3
  • 2
1 Solution
 
andrewstCommented:
The built-in you need is SET_ITEM_INSTANCE_PROPERTY.  That only changes the properties on specified row.
0
 
FBIAGENTCommented:
You should be able to use built-in function

 SET_ITEM_INSTANCE_PROPERTY('<block_name>.Field1', <record_number>, VISUAL_ATTRIBUTE, 'BACKGROUND_YELLOW');

<record_number> is the record number within the block
0
 
InternAuthor Commented:
FBIAGENT - Thanks that helped some.

I have a couple more questions that I need to answer to get this to work correctly.

First - I need to loop through the items in that particular record and change the background for all of them.  What is the best way to do this?  I could hard-code each item, but that is not exactly "good" programming style.

Secondly - What property or value can I use to find out the current record? (i.e. <record_number>)  I am not sure how I can programmable find this value.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
FBIAGENTCommented:
"First - I need to loop through the items in that particular record and change the background for all of them.  What is the best way to do this?  I could hard-code each item, but that is not exactly "good" programming style."

I would put the logic to change the record attribute in the block-level POST-QUERY trigger, and appropriate item-level WHEN-VALIDATE-ITEM triggers

"Secondly - What property or value can I use to find out the current record? (i.e. <record_number>)  I am not sure how I can programmable find this value."

If you put the SET_ITEM_INSTANCE_PROPERTY() in the POST-QUERY and WHEN-VALIDATE-ITEM triggers, then the <record_number> is :system.trigger_record
0
 
InternAuthor Commented:
Thanks - I just need a little clarification on the First point

- If I have 3 items - BLOCK.Field1, BLOCK.Field2, BLOCK.Field3

How do I create a loop that will loop through all the fields in that block.  I know where to put the code, just not sure of the syntax on how to do it.
0
 
FBIAGENTCommented:
You could simply do

set_item_instance_property('block.field1',:sytem.trigger_record,visual_attribute,'background_yellow');
set_item_instance_property('block.field2',:sytem.trigger_record,visual_attribute,'background_yellow');
set_item_instance_property('block.field3',:sytem.trigger_record,visual_attribute,'background_yellow');

or loop through all items in the block as follows

declare
   blk_name                           varchar2(30) := 'BLOCK';
   block_handle                       block;
   block_current_item                 varchar2(30);
   block_last_item                    varchar2(30);
   error_msg                          varchar2(255);
   item_handle                        item;
begin
   -- set up for loop to traverse all the items in the block

   block_handle := find_block(blk_name);
   block_current_item := get_block_property(block_handle, first_item);
   block_last_item := get_block_property(block_handle, last_item);

   -- loop to traverse every item in the block
   loop
      -- verify that the item exists
      item_handle := find_item(blk_name || '.' || block_current_item);

      -- set attribute of the item if condition satisfies
      if ... then
         set_item_instance_property(item_handle,:system.trigger_record,visual_attribute,'BACKGROUND_YELLOW');
      end if;

      -- at end of loop either go to the next item or end looping if at the
      -- last item in this block
      exit when block_current_item = block_last_item;
      block_current_item := get_item_property(item_handle, nextitem);
   end loop;
end;
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now