I've got a question about list items.
I'm using a combo box to show values from a table
where the column is an ID column and the shown labels
are fetched into a record group from an other table.
Is there a way to get the current label from the listbox ?
The built-in GET_LIST_ELEMENT_LABEL can get labels out of
a list item, but it needs a list_index as argument, and I do not
know how to get this list_index for the current label.
Thanks
/Jocke
Cheers
Jhansi
The Help example for Get_List_Element_Count points to one solution, which
is to loop through the List and, when the ID value matches the current
value of your list item, use Get_List_Element_Value.
You could do this whenever required or use a When-List-Changed trigger to
save the label for the current list item in a separate text item (not
displayed on the canvas). Either way I am not aware of an easy solution
that avoids looping through the list.
Jocke <h...@abb.se> wrote in article <01bd50c0$ca60db10$d26add8a@pc2095>...
As you may already know from my previous posting, the reference to
Get_List_Element_Value
should be Get_List_Element_Label.
There are also errors in the Forms example for Get_List_Element_Count,
whereby list_id is undefined and the first loop should use
Get_List_Element_Label.
I would suggest you do something similar to the following:
DECLARE
list_id ITEM := Find_Item(your_block.list_item);
total_list_count NUMBER(2);
loop_index_var NUMBER(2) := 0;
list_value VARCHAR(50);
list_label VARCHAR(50);
BEGIN
/*
** Determine the total number of list elements.
*/
total_list_count := Get_List_Element_Count(list_id);
/*
** Compare the current list item to the list element values.
*/
WHILE loop_index_var < total_list_count
AND list_label = NULL
LOOP
loop_index_var := loop_index_var + 1;
list_value := Get_List_Element_Value(list_id, loop_index_var);
/*
** All list values are unique, so if it matches, get the Label.
*/
IF your_block.list_item = list_value THEN
list_label := Get_List_Element_Label(list_id, loop_index_var);
END IF;
END LOOP;
/*
** If you want to access the label outside this procedure, save it
** in a Control item or some other non-display item.
*/
Control_block.item := list_label;
END;
Hope this is what you're looking for,
Neville Sweet <sweet.ne...@bhp.com.au.no_junk_today_thanks>
FUNCTION GET_LIST_LABEL (from_list_name VARCHAR2)
RETURN VARCHAR2 IS
list_id ITEM := FIND_ITEM(from_list_name);
list_count NUMBER;
current_value VARCHAR2(50);
clicked_value VARCHAR2(50) := NAME_IN(from_list_name);
clicked_label VARCHAR2(50);
list_not_found EXCEPTION;
BEGIN
IF NOT ID_NULL(list_id) THEN
list_count := GET_LIST_ELEMENT_COUNT(list_id);
FOR i IN 1..list_count LOOP
current_value := GET_LIST_ELEMENT_VALUE(list_id, i);
IF clicked_value = current_value THEN
clicked_label := GET_LIST_ELEMENT_LABEL(list_id, i);
RETURN clicked_label'
EXIT;
END IF;
END LOOP;
ELSE
RAISE list_not_found;
END IF;
EXCEPTION
WHEN list_not_found THEN
MESSAGE('List name ' || from_list_name ||
' not found in GET_LIST_ELEMENT');
RAISE FORM_TRIGGER_FAILURE;
END;