Home » Developer & Programmer » Forms » Setting Visual attribute differrent for diffrrent record in tabular block
Setting Visual attribute differrent for diffrrent record in tabular block [message #126933] Thu, 07 July 2005 07:44 Go to next message
Man Mohan Sharma
Messages: 35
Registered: October 2003
Member
can you people help me in Setting differrent color for diffrrent record in a tabular block. We can set visual attribute to current record but is there any facility to set other color to previous record or next records...

Pls. reply
Re: Setting Visual attribute differrent for diffrrent record in tabular block [message #127000 is a reply to message #126933] Thu, 07 July 2005 15:41 Go to previous messageGo to next message
ramisy2k
Messages: 150
Registered: April 2005
Senior Member
YES..ITS NOT A BIG DEAL...
I HAVE DEVISED A METHOD..
U CAN SET AS MANY AS VISUAL ATTRIBUTES..FOR EACH RECORD U WANT TO SEE... BUT U HAVE TO MENTION THE RECORD NO. FOR WHICH U WOULD LIKE TO USE EACH VISUAL ATTRIBUTE..LIKE I HAVE DONE....

CHECK THE ATTACHED FORM..AND ENJOY..

connect scott/tiger...its a dev 6i form

REGARDS
Asim
wordswordsandwords@hotmail.com
  • Attachment: VISUAL.fmb
    (Size: 44.00KB, Downloaded 1390 times)
Re: Setting Visual attribute differrent for diffrrent record in tabular block [message #127081 is a reply to message #127000] Fri, 08 July 2005 08:40 Go to previous messageGo to next message
Man Mohan Sharma
Messages: 35
Registered: October 2003
Member
Thanks for your reply..

But dear thru this I can change only my current record..
and my requirement is when the form opens it will display alternate color for the records contain in a perticular block and it will visible all the times either I select recors or not.
If any clarification get me at
manmohan73@yahoo.com

Thanks
Man Mohan
Re: Setting Visual attribute differrent for diffrrent record in tabular block [message #127165 is a reply to message #127081] Sat, 09 July 2005 07:33 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
In a POST-QUERY trigger, you can set the visual attribute per record.

MHE
Re: Setting Visual attribute differrent for diffrrent record in tabular block [message #127216 is a reply to message #127165] Sun, 10 July 2005 01:18 Go to previous messageGo to next message
Man Mohan Sharma
Messages: 35
Registered: October 2003
Member
Hi MHE,

Thanks.. But can u give me exact code for this...

Re: Setting Visual attribute differrent for diffrrent record in tabular block [message #127219 is a reply to message #127216] Sun, 10 July 2005 03:22 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
I can't give you exact code but here are some pointers:
- evaluate the record_number: if it's odd use one visual_attribute and if it's even use another.
- use a set_item_instance_property built-in for each item you want to change.

This could be part of your post-query trigger (careful, not tested!)

BEGIN
  IF MOD( to_number(:system.cursor_record)
        , 2
        ) = 1 
  THEN
    SET_ITEM_INSTANCE_PROPERTY( :system.cursor_record
                              , 'theblock.theitem'
                              ,  visual_attribute
                              , 'Your_first_visual_attribute');
  ELSE
    SET_ITEM_INSTANCE_PROPERTY( :system.cursor_record
                              , 'theblock.theitem'
                              ,  visual_attribute
                              , 'Your_other_visual_attribute');
  END IF;
END;

HTH,
MHE
Re: Setting Visual attribute differrent for diffrrent record in tabular block [message #127318 is a reply to message #127219] Mon, 11 July 2005 04:53 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
I've found some time yesterday and I've created a small example based on the SCOTT.EMP table.

:SYSTEM.CURSOR_RECORD seemed to be a wrong choice in the code...

As always: Check the code before usage!

HTH,
MHE

Re: Setting Visual attribute differrent for diffrrent record in tabular block [message #127483 is a reply to message #127318] Mon, 11 July 2005 20:22 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
':system.cursor_record' is only useful if all the fields on the line come from the same block. I often find it better to use 'Get_Block_Property( bk_id, CURRENT_RECORD);' so that I know which block and record I am changing.

David
Re: Setting Visual attribute differrent for diffrrent record in tabular block [message #127545 is a reply to message #127483] Tue, 12 July 2005 02:46 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
Good point, that's why I attached the demo Form, which uses the get_block_property. I realised ( a little late Very Happy ) that :System.cursor_record is a poor choice.

MHE
Re: Setting Visual attribute differrent for diffrrent record in tabular block [message #127552 is a reply to message #127545] Tue, 12 July 2005 03:15 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Sorry ... I'm not permitted to download forms onto this PC so I didn't look inside your sample form.

We do use it however for our field specific help display.
   fld_help (:system.current_form, :system.cursor_item, a_date);

There is a table in our system which has help information based on form and field (block.item) and we use a standard way of showing the information.

David
Re: Setting Visual attribute differrent for diffrrent record in tabular block [message #127567 is a reply to message #127552] Tue, 12 July 2005 04:55 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
Code in post-query:

Declare
	v_curr_rec PLS_INTEGER := get_block_property('EMP',CURRENT_RECORD);
Begin
	if mod(v_curr_rec, 2) = 1
	then -- odd_records: white
	  set_block_color('EMP', v_curr_rec, 'WHITE');
	else -- even records: gray
		set_block_color('EMP', v_curr_rec, 'GRAY');
	end if;
End;


Here's the program unit's code:

PROCEDURE set_block_color (piv_block_name IN VARCHAR2, pin_rec_number IN NUMBER, piv_color IN VARCHAR2)
IS
/* PROCEDURE SET_BLOCK_COLOR
|| Purpose: Sets all text items in a block to a certain color through visual attributes.
||
|| Parameters: block name, record_number, color
||
|| DEMO: Verify before use in a production environment!
*/
  v_item      VARCHAR2 (120);
  v_va_name   VARCHAR2 (120);
  v_va_id     visualattribute;
BEGIN
  -- construct the visual attribute's name ( convention: VA_<<COLOR>> )
  v_va_name := 'VA_' || piv_color;
  -- verify the existance of the visual attribute
  v_va_id := FIND_VA (v_va_name);

  IF ID_NULL (v_va_id)
  THEN
    -- visual attribute not found, default to 'WHITE'
    v_va_name := 'WHITE';
  END IF;

  -- go to the first item in the block
  v_item := GET_BLOCK_PROPERTY (piv_block_name, first_item);
  
  <<va_loop>>
  LOOP
    -- check whether the item is a text item and whether the visual attribute was found
    IF     (GET_ITEM_PROPERTY (piv_block_name || '.' || v_item, item_type) = 'TEXT ITEM')
       AND NOT ID_NULL (v_va_id)
    THEN
      -- set the item's visual attribute
      SET_ITEM_INSTANCE_PROPERTY (piv_block_name || '.' || v_item, pin_rec_number, visual_attribute, v_va_name);
    END IF;

    -- if we've reached the last item in the block, exit the loop.
    EXIT va_loop WHEN v_item = GET_BLOCK_PROPERTY (piv_block_name, last_item);
    v_item := GET_ITEM_PROPERTY (piv_block_name || '.' || v_item, nextitem);
  END LOOP va_loop;
END;


Seems to do the job. For the original poster it's not that hard to modify it to his needs.

MHE
Re: Setting Visual attribute differrent for diffrrent record in tabular block [message #336614 is a reply to message #127318] Mon, 28 July 2008 06:52 Go to previous message
jale
Messages: 15
Registered: May 2008
Location: TURKEY
Junior Member
Code is great..

But I have a problem that my block contains items which aren't on canvas and block is a view.

I tried in your form, if an item is not on canvas, code is working either, but in my forms, it doesn't work, I looked for item properties, I found nothing, so I add canvas property to code.

Thank you


PROCEDURE set_block_color (piv_block_name IN VARCHAR2, pin_rec_number IN NUMBER, piv_color IN VARCHAR2)
IS
/* PROCEDURE SET_BLOCK_COLOR
|| Purpose: Sets all text items in a block to a certain color through visual attributes.
||
|| Parameters: block name, record_number, color
||
|| DEMO: Verify before use in a production environment!
*/
  v_item      VARCHAR2 (120);
  v_va_name   VARCHAR2 (120);
  v_va_id     visualattribute;
  v_canvas    varchar2 (120);
BEGIN
  -- construct the visual attribute's name ( convention: VA_<<COLOR>> )
  v_va_name := 'VA_' || piv_color;
  -- verify the existance of the visual attribute
  v_va_id := FIND_VA (v_va_name);

  IF ID_NULL (v_va_id)
  THEN
    -- visual attribute not found, default to 'WHITE'
    v_va_name := 'WHITE';
  END IF;

  -- go to the first item in the block
  v_item := GET_BLOCK_PROPERTY (piv_block_name, first_item);
 
  <<va_loop>>
  LOOP
  	--check the item_canvas
  	if GET_ITEM_PROPERTY (piv_block_name || '.' || v_item, item_CANVAS) is not  null then
  	 v_canvas:=GET_ITEM_PROPERTY (piv_block_name || '.' || v_item, item_CANVAS);
  	 end if;
    -- check whether the item is a text item and whether the visual attribute was found
    IF     (GET_ITEM_PROPERTY (piv_block_name || '.' || v_item, item_type) = 'TEXT ITEM')
       AND NOT ID_NULL (v_va_id) 
       AND (GET_ITEM_PROPERTY (piv_block_name || '.' || v_item, item_CANVAS) = v_canvas)
    THEN
      -- set the item's visual attribute
      SET_ITEM_INSTANCE_PROPERTY (piv_block_name || '.' || v_item, pin_rec_number, visual_attribute, v_va_name);
    END IF;

    -- if we've reached the last item in the block, exit the loop.
    EXIT va_loop WHEN v_item = GET_BLOCK_PROPERTY (piv_block_name, last_item);
    v_item := GET_ITEM_PROPERTY (piv_block_name || '.' || v_item, nextitem);
  END LOOP va_loop;
END;

[Updated on: Mon, 28 July 2008 07:35]

Report message to a moderator

Previous Topic: Cancel Query
Next Topic: validation of item by comparing with another item of previous record in a multirecord block
Goto Forum:
  


Current Time: Sun Dec 11 04:23:33 CST 2016

Total time taken to generate the page: 0.08863 seconds