cancel
Showing results for 
Search instead for 
Did you mean: 

To populate the item list box item

Former Member
0 Kudos

Hi,

I have already binded the item list box to a node.. as i cant bind to an attribute...

but i don't know how to populate the node... is it like i need to create multiple attributes for all data that is to be shown in the list .. or I need to bind it using coding.. can any one provide me a demo code....

I will be really grateful.

Thanks and Regards

Tenzin

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Tenzin,

I created a node called 'ITEMLIST' of cardinality 0:n and added an attribute to it called 'ITEMLIST_ELEMENT'. I bound the datasource to the 'ITEMLIST' node and the text property to the 'ITEMLIST_ELEMENT'.

I gave a supply function for the node 'ITEMLIST'.

The code is as follows:

METHOD sf_itemlist .

DATA lt_itemlist TYPE wd_this->elements_itemlist.

DATA ls_itemlist LIKE LINE OF lt_itemlist.

ls_itemlist-item_list_element = 'Kolkata'.

APPEND ls_itemlist TO lt_itemlist.

ls_itemlist-item_list_element = 'Kohima'.

APPEND ls_itemlist TO lt_itemlist.

  • bind all the elements

node->bind_table(

new_items = lt_itemlist ).

  • set_initial_elements = abap_true ).

ENDMETHOD.

Regards,

Prosenjit.

Answers (3)

Answers (3)

former_member402443
Contributor
0 Kudos

Hi Tenzin,

For populating the values in the list box, first u hv to bind the

Bind DATASOURCE property of ITEMLISTBOX with your node says - AIRLINE,then.

Bind TEXT property of ITEMLISTBOX with your attribute of AIRLINE node says CARRID and also

set the cardinality of the node to 0...n.

then for data population you can create a supply function - fill_airlineid or u can retreive data in the wddoinit method of your view.

Supply function

method fill_airlineid .

    • data declaration

data lt_airline type wd_this->elements_airline.

data ls_airline like line of lt_airline.

select distinct carrid

from sflight

into table lt_airline.

  • bind all the elements

node->bind_table(

new_items = lt_airline

set_initial_elements = abap_true ).

endmethod.

Hopes this will helps you.

Regards

Manoj Kumar

Former Member
0 Kudos

hi,

->You have created a item list box UI Element and binded it to Context Node say Airline.

-> Now you got to have attribute under this node which will be availble in the list box. Lets say attribute under your node is Carrid.

-> Now in the Context Node property you have property Supply Function.

-> Lets say supply function created is Fill_List.

->Now this is a method created by you which will supply values to the node (Airline) having context attribute Carrid.

-> Now write the following Code to populate the node.

method fill_list .

    • data declaration

data lt_airline type wd_this->elements_airline.

data ls_airline like line of lt_airline.select distinct carrid

from sflight

into table lt_airline.* @TODO compute values

  • e.g. call a data providing FuBa* bind all the elements

node->bind_table(

new_items = lt_airline

set_initial_elements = abap_true ).

*

endmethod.

Now you are done with the population of values to the node.

Other way around is populate the node in WdDoinit method.

You can also write the above code and populate the values in the item list box UI Element using above code in wddoinit.

I hope it helps.

Former Member
0 Kudos

You need to bind it to node with 0..n or 1..n cardinality. Thus a internal table should be the best candidate for it...

use bind_table method of IF_WD_CONTEXT_NODE to bind the table to the node.

Greetings

Prashant