on 10-29-2010 8:17 AM
I m trying to build the following things in 1 view :
UI element of type ItemListbox , and 2 button (up and down butto ; to move the selected item in the list ).
and then i have a button calles 'SAVE' to save the data in the database.
Databasetabel had the following fields : Description , priority.
so at the first time the listbox will be displayed from db tabel order by priority.
Up and down buttton had to change the priority.
save button : save data with the new value of priority.
so i m looking for some sample or/and sugegstions how to build this
Edited by: Moo Yac on Oct 29, 2010 11:42 AM
Hi can,
To be more clear :
I have in my cntext a node Cockpit_list1 with cardinality 0..n , and 1 attribuut item_name (type string).
for testing : this is my wddoinit method:
Types : Begin of ty_list,
item_name type char30,
PRIORITY type BEPRIO,
End of ty_list.
Data :
wa_item_test type ty_list,
lt_elements_list1 type table of ty_list,
lo_nd_cockpit_list1 type ref to if_wd_context_node.
wa_item_test-item_name = 'test1'.
wa_item_test-priority = 1.
append wa_item_test to lt_elements_list1.
wa_item_test-item_name = 'test2'.
wa_item_test-priority = 2.
append wa_item_test to lt_elements_list1.
lo_nd_cockpit1_list = wd_context->get_child_node( name = wd_this->wdctx_cockpit_list1 ).
lo_nd_cockpit1_list->bind_table( new_items = lt_elements_list1
set_initial_elements = abap_true ).
-
I have under the listimembox 2 buttons : up/down
if a select an element and it;s not the first and not the last , i can move it up and down.
In your code i don't see any thing about changing the index , mmoving up/down
can you pls give me the code ..this wil help me a lot
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi, Moo Yac.
Explain it clearly.
(1). Initially, you should retrieve the data from DB into one table, and then bound the table to the context node which is bound to the Item list UI element. off course, as you already mentioned, the order is assured from DB.
-
As you said in your previous post, you have already do this in WDdoInt. Okay, very good.
(2). When you select one item, you set the lead selection of the context node, just one EXAMPLE.
-
Now, pls implement the action of "onSelect"(i cannot rememe cleary..you can look for..). Then use the following coding to set the lead selection
lo_node->set_lead_selection( context_element ). "you can set it in the onLeadSelect
(3). you "UP","DOWN" button
you should "INVALIDE" the lo_node and then sort the table separately, then bind the table to the context node again, then set the lead selection to keep the selected item no changed.
-
pls try the following code in your action handler of button "UP".
Types : Begin of ty_list,
item_name type char30,
PRIORITY type BEPRIO,
End of ty_list.
data:
ls_table type ty_list,
lt_table type table of ty_list.
lw_priority type BEPRIO.
FIELD-SYMBOLS: <fs_table> type ty_list.
*1. get the selected item
lo_elem = lo_Node->GET_element( ).
lo_elem->get_Attribute(
exporting
Name = 'Item_name'
importing
Value = lw_key ).
*2. get all data
lo_Node->GET_STATIC_ATTRIBUTES_TABLE(
importing TABLE = lt_table ).
*3. sort the table-- Move the selected item upforward one step
read table lt_table assigning <fs_table> with key Item_name = lw_key.
<fs_table>-priority = <fs_table>-priority - 1. "move upward 1 step.
lw_priority = <fs_table>-priority. "record the priority
"modify the old record
loop lt_table assigning <fs_table> where Item_name <> lw_key and
priority = lw_priority.
<fs_table>-priority = <fs_table>-priority + 1. "move downward 1 step.
endloop.
*4.Invalidate the node
lo_node->invalidate( ).
*5.bind table again
lo_node->bind_table( lt_data ).
*6. set lead selection.
lt_elems = lo_node->GET_ELEMENTS( ).
loop at lt_elems into lo_Elem.
* get single attribute
lo_elem->get_Attribute(
exporting
Name = 'Item_name'
importing
Value = lw_key2 ).
* check the selected
if lw_key = lw_key2.
lo_node->set_lead_selection( lo_elem ).
exit.
endif.
endloop.
-
You can try, Best wishes.
Hi can,
Thanks a lot , problem solved .U get your points:)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi can tang,
In the wddoniit i select alle data from db table.
hoe i can move the elements up and down in the listitem?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi, Moo Yac.
From your description, in fact the requirement is a little simple.
Very glad to discuss with you about this topic.
In summary, i share you some clue.
(1). Initially, you should retrieve the data from DB into one table, and then bound the table to the context node which is bound to the Item list UI element. off course, as you already mentioned, the order is assured from DB. just use
lo_node->bind_table( lt_data ).
lo_node->set_lead_selection_index( -1 ). "No select item initially
(2). When you select one item, you set the lead selection of the context node, just one EXAMPLE.
lo_node->set_lead_selection( context_element ). "you can set it in the onLeadSelect
(3). you "UP","DOWN" button
you should "INVALIDE" the lo_node and then sort the table separately, then bind the table to the context node again, then set the lead selection to keep the selected item no changed.
EXAMPLE.
*1. get the selected item
lo_elem = lo_Node->GET_element( ).
lo_elem->get_Attribute(
exporting
Name = 'Description'
importing
Value = lw_key ).
*2. get all data
lo_Node->GET_STATIC_ATTRIBUTES_TABLE(
importing TABLE = lt_table ).
*3. sort the table--"JUST ABAP
*4.Invalidate the node
lo_node->invalidate( ).
*5.bind table again
lo_node->bind_table( lt_data ).
*6. set lead selection.
lt_elems = lo_node->GET_ELEMENTS( ).
loop at lt_elems into lo_Elem.
* get single attribute
lo_elem->get_Attribute(
exporting
Name = 'Description'
importing
Value = lw_key2 ).
* check the selected
if lw_key = lw_key2.
lo_node->set_lead_selection( lo_elem ).
exit.
endif.
endloop.
hope it can help you a little,
Best wishes.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.