cancel
Showing results for 
Search instead for 
Did you mean: 

Drop down by list box in table UI element

Former Member
0 Kudos

Hi ,

Can anyone provide me the example on how to use the drop down by index UI element inside the table UI element.

I want one of the table cell needs to be editable and able to except the values from drop down list box.

Regards,

Amar Kamat

Accepted Solutions (1)

Accepted Solutions (1)

uday_gubbala2
Active Contributor
0 Kudos

Now you have realized the first part of the requirement i.e, displaying a dropdown and filling it with your desired value set. You can easily have a blank column in your table which should get its value from the value selected in the DropDownByIndex. (Just as how you changed the cell editor of your textview to an DropDownByIndex, you need to change your texteditor to an InputField.) Your DropDownByIndex has a property called "onSelect" which gets triggered whenever you select any value from your dropdown. So create an action handler for this property. Using this you can fetch the value selected by the user & modify the corresponding value of your input field to display the same.

Regards,

Uday

PS: As a reference you can try go through this [free sample version|http://www.sap-press.de/download/dateien/1079/sappress_web_dynpro_for_abap.pdf] of Ulli Hoffman's textbook Web Dynpro For ABAP. Go through section 3.3.1 "Using Dropdown Lists". Hope that this helps resolve your problem.

Former Member
0 Kudos

Hi Uday,

Thanks for the demo example.

I have used the Drop down by index element .

I have created the context node 'TABLE' which contains the subnode 'DropDownByIndx' which holds the value set that needs to be displayed , also assigned the action for OnSelect for UI element .

I also created the attribute 'KEY_SELECTED' in node 'TABLE'

Can you please tell me how the current value in drop down can be assigned to the attribute 'KEY_SELECTED' for each row of table.

Regards,

Amar Kamat

uday_gubbala2
Active Contributor
0 Kudos

Hi Amar,

Can you share your mail so that i can send out a full working code with snapshots? I have a document of a similar example that I had created earlier. That would be a lot easier for you that way.

Regards,

uday

For the users who might be interested in the solution. this is the coding that I put inside the action handler for onSelect event of the dropdown. I have a column in my table which is bound to the STRING attribute EDITABLE_FIELD. am displaying this entire columns fields as input fields. When the user selects a value from the dropdown in column URL I am populating the EDITABLE_FIELD column with the selected value.

method ONACTIONON_DROP_DOWN_SELECT .
  data: lr_element type ref to if_wd_context_element,
        lv_index_table type i,
        lv_index type i,
        lt_urls type wd_this->elements_urls,
        wa_urls type wd_this->element_urls,
        wd_node type ref to if_wd_context_node.

*** Get row number from which dropdown value was selected
  lr_element = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
  lv_index_table = lr_element->get_index( ).

*** Get the index of value within dropdown which is selected
  lv_index = wdevent->get_int( name = 'INDEX' ).

*** Fetch all the dropdown values into an internal table
  wd_node = wd_context->path_get_node( 'TABLE_SOURCE.URLS' ).

  CALL METHOD WD_NODE->GET_STATIC_ATTRIBUTES_TABLE
    EXPORTING
      FROM  = 1
      TO    = 2147483647
    IMPORTING
      TABLE = lt_urls.
*** Obtain the value selected in the dropdown by the user using the index obtained
  read table lt_urls into wa_urls index lv_index.

*** Set the input fields value to the same value as selected in the dropdown
  wd_node = wd_context->get_child_node( name = 'TABLE_SOURCE' ).

  wd_node->set_attribute( exporting index = lv_index_table
                                    name  = 'EDITABLE_FIELD'
                                    value = wa_urls-url ).
endmethod.

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

Hi Uday,

The code u have provided in post solved my error.

Thanks a lot.

Regards,

Amar Kamat

Answers (3)

Answers (3)

uday_gubbala2
Active Contributor
0 Kudos

Hi Amar,

You need to create 2 context nodes in your component. One node would contain the list of values to be displayed in the table & the other would contain set of KEY/VALUE pairs to be bound to the DropDownByIndex.

Consider the case that you have 2 nodes TABLE_SOURCE & URLS. The node TABLE_SOURCE contains 3 attributes CARRID, CARRNAME & CURRCODE to be displayed in the table. In addition the table has a column which displays a list of URL's in a DropDownByIndex element.

So for this create the node URLS as a subnode of TABLE_SOURCE. Now under this node define 2 attributes:

URL type STRING & KEY type STRING.

To fill the values for these nodes define a SUPPLY FUNCTION (S_TABLE_SOURCE) for the parent node TABLE_SOURCE. Below is the coding within the supply function.

method s_table_source.

* data declaration
  data:
    lt_table_source type if_main_view=>elements_table_source,
    table_source    like line of lt_table_source,
    lt_urls         type if_main_view=>elements_urls,
    url             like line of lt_urls,
    tabix           type sytabix,
    lr_element      type ref to if_wd_context_element,
    lr_child_node   type ref to if_wd_context_node.

* get all carriers
  cl_wd_flight_model=>get_scarr( importing et_scarr = lt_table_source ).

* bind all the elements
  node->bind_table(
    new_items =  lt_table_source
    set_initial_elements = abap_true ).

* fill the sub node with some URLs
  loop at lt_table_source into table_source.
    tabix = sy-tabix.
    clear lt_urls[].
    do 5 times.
      url-key = sy-index * tabix.
      condense url-key.
      concatenate `www.` url-key `.com` into url-url.
      insert url into table lt_urls.
    enddo.
    lr_element = node->get_element( tabix ).
    lr_child_node = lr_element->get_child_node( 'URLS' ).
    lr_child_node->bind_table( lt_urls ).
  endloop.
endmethod.

Now as how explained by Lekha in go to your tables desired cell editor & change the textview to dropdown by index. Now bind the "texts" property of the DropDownByIndex element to the URL attribute which we had created under node URLS. (i.e., MAIN_VIEW.TABLE_SOURCE.URLS.URL)

Now when you test your application you would have the table getting displayed with the DropDownByIndex filled with a set of values. All the scenario that I have explained is available for you in the standard SAP component DEMO_VARIABLE_DROPDOWN ! Check it out & you would understand as to how to implement the logic.

Regards,

Uday

Former Member
0 Kudos

Hi Amar,

go thru this forum for details on dropdownbyindex.

http://help.sap.com/saphelp_erp2005/helpdata/EN/dd/b0884118aa1709e10000000a155106/content.htm

also go thru this thread.

thnks

Former Member
0 Kudos

Hi,

When ever you create a table for that column in the editor, you can change the textview to dropdown by index.

For this you need to bind the node to the property of the dropdown.

Now fill this node for dropdowns.

Create a node with 0:N or 1:N cardinality for the dropdowns. Fill this node.

When you do table binding in the layout, change the cell editor to dropdown by index for this column.

Now bind the selectedtexts property of this dropdown by index to the node you have filled above.

Regards,

Lekha.