Home » Developer & Programmer » Forms » Moving data between two list items (Oracle Forms6i)
Moving data between two list items [message #485466] Wed, 08 December 2010 06:12 Go to next message
soujanya_g
Messages: 7
Registered: December 2010
Location: bangalore
Junior Member
Hi,

My form has two list boxes and two buttons add and remove.
As and when i click add button, the selected value from left hand side list item should get populated to right hand side list item. And When I click Remove button, it should do vice versa.

Could you please help me in this issue. If there are any posts related to this earlier, please share it.

Thanks
Re: Moving data between two list items [message #485586 is a reply to message #485466] Wed, 08 December 2010 23:45 Go to previous messageGo to next message
mehediu
Messages: 46
Registered: February 2010
Location: Dhaka
Member

Hi,

i use the following code to add item in list and remove item from list
you can try , may be it will help you .
declare
  rg_name VARCHAR2 (15) := 'My_Group'; 
  rg_id   RecordGroup; 
  gc_id   GroupColumn; 
  fetch_value GroupColumn;
  LIST_ID ITEM;
  L NUMBER;
  QUANTITY CHAR(8);
  
begin
  :GLOBAL.SL :=0;
IF(:BLK.LIST IS NULL   OR :BLK.LIST='')THEN
  null;
else
  :GLOBAL.SL := :GLOBAL.SL+1;
  rg_id := Find_Group( rg_name );
 IF Id_Null(rg_id) THEN 
  rg_id := Create_Group( rg_name ); 
  gc_id := Add_Group_Column(rg_id, 'Key',CHAR_COLUMN, 8); 
  gc_id := Add_Group_Column(rg_id, 'Value',CHAR_COLUMN,8); 
 END  IF;
END  IF;	
		
		
IF (:GLOBAL.SL = 1) THEN 
  :GLOBAL.FIRST_VALUE:=RTRIM(LTRIM(:BLK.LIST));
  Add_List_Element('BLK.LIST', :GLOBAL.SL, RTRIM(LTRIM(:BLK.LIST)), RTRIM(LTRIM(:BLK.LIST)));

ELSE
  LIST_ID:=FIND_ITEM('BLK.LIST');
  RETRIEVE_LIST(LIST_ID, rg_id);  
  fetch_value:=Find_Column('My_Group.Key');
		
  L:=GET_GROUP_ROW_COUNT(RG_ID);
	
 FOR I IN 1..L LOOP 
  quantity := Get_Group_CHAR_Cell(FETCH_VALUE,I);
  IF RTRIM(LTRIM(TO_NUMBER(:BLK.LIST)))=TO_NUMBER(QUANTITY) THEN
						:GLOBAL.ST:='N';
  message('Already Exists.'); 
  BREAK;
  END  IF;	
 END LOOP;	
	
 IF(:GLOBAL.ST='N')THEN
  message('Already Exists.');
 ELSIF(:GLOBAL.ST='Y')THEN
 message('Already Exists.');
Add_List_Element('BLK.LIST', :GLOBAL.SL, RTRIM(LTRIM(:BLK.LIST)), RTRIM(LTRIM(:BLK.LIST)));				
END  IF;	
END  IF;		
end ;


and for remove item from list

DECLARE
	LIST_ID item;
	rg_id   RecordGroup; 
	gc_id   GroupColumn; 
	rg_name VARCHAR2 (15) := 'My_Group'; 
	ln_Index NUMBER:=0;
	lv_Value VARCHAR2 (255):=:BLK.LIST; --Selected Item Value in the List
	E_BLANK  EXCEPTION;
	a number;
BEGIN
			LIST_ID:=FIND_ITEM('BLK.LIST');
			
	   	IF :BLK.LIST IS NULL   THEN
	   		 --RAISE E_BLANK;
	   		 message('ID does not exist.');
	   	END  IF;
	   	
	   	
	   	IF Id_Null(rg_id) IS NULL   THEN 
	   	:BLK.LIST:=null;	   	
	   	GO_ITEM('BLK.LIST');
	   	ELSE	   	
	   	a := Get_List_Element_Count(list_id);
	
			FOR i IN 1..a  LOOP
					IF Get_List_Element_Value('LIST',i) = lv_Value THEN
					ln_Index:= i;
					EXIT;
					END  IF;
			END LOOP;
	
	    Delete_List_Element('LIST',ln_Index);
	    :BLK.LIST:=null;
	   	END  IF;
	   	
END;


use this as your application want.

Thanks
best of luck.
Re: Moving data between two list items [message #485592 is a reply to message #485586] Thu, 09 December 2010 00:00 Go to previous messageGo to next message
soujanya_g
Messages: 7
Registered: December 2010
Location: bangalore
Junior Member
Hi,

Many thanks for the reply. Actually I have written code as per below in When Button Pressed trigger of Add Button.
As soon as I add the selected list element to the right hand side list item 'LIST5', the list element should get deleted from the left hand side list item 'LIST4'. So, could you please tell me how to get index value of the 'LIST4'?

Thanks,

Declare
lst5 ITEM:=FIND_ITEM('list5');
lst4 ITEM := FIND_ITEM('list4');

Begin

Message(:list4 ||' is the current value selected in the list LIST4');
if :list4 = ' ' then
message('no values selected');
else
ADD_LIST_ELEMENT(lst5, GET_LIST_ELEMENT_COUNT(lst5)+1, :list4, :list4);

end if;
message(get_list_element_count(lst5)||' values are in list5');
end;
Re: Moving data between two list items [message #485596 is a reply to message #485592] Thu, 09 December 2010 00:11 Go to previous messageGo to next message
mehediu
Messages: 46
Registered: February 2010
Location: Dhaka
Member

Hi,

to get index value of the 'LIST4'
LIST_ID:=FIND_ITEM('LIST4');
a := Get_List_Element_Count(list_id);
	
FOR i IN 1..a  LOOP
 IF Get_List_Element_Value('LIST',i) = :LIST4 THEN
 ln_Index:= i;
 EXIT;
 END  IF;
END LOOP;
	
Delete_List_Element('LIST',ln_Index);
:LIST4:=null;
END  IF;



Thanks
Re: Moving data between two list items [message #485829 is a reply to message #485596] Fri, 10 December 2010 05:55 Go to previous messageGo to next message
soujanya_g
Messages: 7
Registered: December 2010
Location: bangalore
Junior Member
Hi,

Thanks for the reply. It is working fine with no issues.
Sorry to bother you again. I want the REMOVE button to be disabled when the right hand side list item is empty.

I tried using the below code in When list changed event of right hand side button. It doesn't work.

If Get_list_element_count('list_right')=0 or :list_right=' ' then
set_item_property('pb_remove',enabled,property_false);
end if;

This code doesn't work and the button is still enabled.

Please help.

Thanks
Re: Moving data between two list items [message #485946 is a reply to message #485829] Sat, 11 December 2010 21:59 Go to previous messageGo to next message
mehediu
Messages: 46
Registered: February 2010
Location: Dhaka
Member

Hi,
Sorry i was in weekend thats why i could not answer you.

I think
Get_List_Element_Count(list_id) 

will give you select items count, you rather
use the
GET_GROUP_ROW_COUNT(RG_ID);

to get the total no of element in that list.

and better use it
WHEN-NEW-FORM-INSTANCE and
add button trigger(WHEN-BUTTON-PRESSED)
and also in delete button(WHEN-BUTTON-PRESSED)

Thanks



Re: Moving data between two list items [message #485947 is a reply to message #485946] Sat, 11 December 2010 22:21 Go to previous messageGo to next message
mehediu
Messages: 46
Registered: February 2010
Location: Dhaka
Member

Hi,

Get_List_Element_Count(list_id) 

will work also. but you have to use it
in proper position.

where you use your code
i think you better use it in
WHEN-NEW-FORM-INSTANCE
If Get_list_element_count('list_right')=1 then
set_item_property('pb_remove',enabled,property_false);
end if;


and enable it in add button trigger.

Thank you.
Re: Moving data between two list items [message #486019 is a reply to message #485947] Sun, 12 December 2010 22:41 Go to previous messageGo to next message
soujanya_g
Messages: 7
Registered: December 2010
Location: bangalore
Junior Member
Hi,

1. The two buttons ADD and REMOVE will be disabled during WHEN NEW FORM INSTANCE trigger.
2. When the LIST LEFT is populated with values ADD button is enabled.
3. When the LIST RIGHT is populated with values REMOVE button is enabled.

Now my requirement is when LIST RIGHT is empty then the REMOVE button should be disabled.

If Get_list_element_count('list_right')=1 then
set_item_property('pb_remove',enabled,property_false);
end if;

I am not able to do this. I tried using the above code in WHEN LIST CHANGED event of LIST RIGHT. But it doesn't work.

Please advice,

Many thanks.

Re: Moving data between two list items [message #486025 is a reply to message #486019] Mon, 13 December 2010 00:52 Go to previous messageGo to next message
mehediu
Messages: 46
Registered: February 2010
Location: Dhaka
Member

Hi,

i think in WHEN LIST CHANGED event, it will not work properly.
you better right this code in ADD & REMOVE button. when REMOVE
button pressed it will check that list is empty or not after
removing the current item. if Empty then first you need to go
another item then you can disable REMOVE button. otherwise it
will give error.
go_item('LIST LEFT');
set_item_property('pb_remove',enabled,property_false);


hope my suggestion will help you.
Thanks
Re: Moving data between two list items [message #486193 is a reply to message #485466] Tue, 14 December 2010 04:12 Go to previous messageGo to next message
soujanya_g
Messages: 7
Registered: December 2010
Location: bangalore
Junior Member
Thanks very much for the message. Unfortunately I am unable to do this. What ever i do it still doesn't seem to work. Just banging head on to this.

I have enclosed the screenshot of the form. fyi,
Thanks,

  • Attachment: form.JPG
    (Size: 74.96KB, Downloaded 759 times)
Re: Moving data between two list items [message #486214 is a reply to message #486025] Tue, 14 December 2010 05:25 Go to previous message
soujanya_g
Messages: 7
Registered: December 2010
Location: bangalore
Junior Member
Hi,
Its working now. Actually the problem was list item even though it is empty the count is showing as 1.
so if we check
If get_list_element_count('list_right')= 1 then
go_item('list_left');
set_item_property('pb_remove',enabled,property_false);
end if;

Many thanks for all the support.
Cheers
Previous Topic: QUESTIONS
Next Topic: How to save image in oracle 9i and display the image on forms 6i
Goto Forum:
  


Current Time: Thu Sep 19 14:01:17 CDT 2024