Moving data between two list items [message #485466] |
Wed, 08 December 2010 06:12 |
|
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 |
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 #486214 is a reply to message #486025] |
Tue, 14 December 2010 05:25 |
|
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
|
|
|