Skip to Content
author's profile photo Former Member
Former Member

Add Childelements to Accordion_Item dynamically

I have a webdynpro application in which I add an Accordion with some Accordion Items dynamically.


Now I want to add an inputfield and a caption (several/more than one ui-elements) to an Accordion Item.

The problem is, that I only found the method set_content. (This method can only add one item)

data: lr_acc_item TYPE REF TO CL_WD_ACCORDION_ITEM.

CALL METHOD cl_wd_caption=>new_caption
EXPORTING
text = wa_txt
RECEIVING
control = lr_caption.

CALL METHOD lr_acc_item->SET_CONTENT
EXPORTING
the_content = lr_caption.

With this code, I have the caption in the accordion_item.

I tried to add a transparent controller, which contains my elements, with the method set_content but without success. (Error message)

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Dec 04, 2013 at 01:34 PM

    Hi,

    You can add Transparent Container to Accordion Item and add multiple UI elements in Transparent Container.

    I jus tried and here is the sample code: Write the below code in domodifyview method.

    METHOD wddomodifyview .

    DATA lr_accordion_item TYPE REF TO cl_wd_accordion_item.

    DATA: lr_accordion TYPE REF TO cl_wd_accordion.

    DATA: lr_root TYPE REF TO cl_wd_uielement_container,

    lr_tcontainer TYPE REF TO cl_wd_transparent_container.

    DATA: input_field TYPE REF TO cl_wd_input_field,

    input_field1 TYPE REF TO cl_wd_input_field,

    flow_data TYPE REF TO cl_wd_flow_data.


    *Get Root Container

    lr_root ?= view->get_root_element( ).

    *Create Accordion

    lr_accordion = cl_wd_accordion=>new_accordion(

    id = 'AC' " dummy test ID; use meaningful ID

    view = view ).

    *Create Accordian Item

    lr_accordion_item = cl_wd_accordion_item=>new_accordion_item( id = 'AI'

    title = 'AccordionItem'

    tooltip = 'Tooltip AccordionItem 1' ) .

    * Create Transparent Container

    lr_tcontainer = cl_wd_transparent_container=>new_transparent_container( ).

    * Create flow data to TC

    cl_wd_flow_data=>new_flow_data( lr_tcontainer ).

    cl_wd_flow_layout=>new_flow_layout( lr_tcontainer ).


    *Create 2 input fields

    input_field = cl_wd_input_field=>new_input_field(

    bind_value = 'TEXT1' ). " TEXT1 is the attribute name in context

    input_field1 = cl_wd_input_field=>new_input_field(

    bind_value = 'TEXT2' ).

    * Set flow data to input fields

    flow_data = cl_wd_flow_data=>new_flow_data( input_field ).

    input_field->set_layout_data( flow_data ).

    flow_data = cl_wd_flow_data=>new_flow_data( input_field1 ).

    input_field1->set_layout_data( flow_data ).

    *Add 2 input fields to Transparent Container

    lr_tcontainer->add_child( input_field ).

    lr_tcontainer->add_child( input_field1 ).

    *Set Transparent Container to Accordion Item

    lr_accordion_item->set_content( lr_tcontainer ).

    * Add Accordion item to Accordion.

    lr_accordion->add_item( lr_accordion_item ).

    *Set Flow layout to Accordion

    flow_data = cl_wd_flow_data=>new_flow_data( lr_accordion ).

    lr_accordion->set_layout_data( flow_data ).

    *Now add Accordion to Root Container

    lr_root->add_child( lr_accordion ).

    ENDMETHOD.

    Hope this helps u.,

    Regards,

    Kiran

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Alexander!

      I think you can do the same as Kiran proposes. Just replace the calls to:

      CL_WD_FLOW_DATA=>NEW_FLOW_DATA( ).

      with

      CL_WD_MATRIX_DATA=>NEW_MATRIX_DATA( ) or CL_WD_MATRIX_HEAD_DATA=>NEW_MATRIX_HEAD_DATA( ).

      CL_WD_FLOW_LAYOUT=>NEW_FLOW_LAYOUT( ).

      with

      CL_WD_MATRIX_LAYOUT=>NEW_MATRIX_LAYOUT( ).

      And replace the object

      FLOW_DATA TYPE REF TO CL_WD_FLOW_DATA

      with

      MATRIX_DATA TYPE REF TO CL_WD_MATRIX_DATA or

      MATRIX_HEAD_DATA TYPE REF TO CL_WD_MATRIX_HEAD_DATA.

      Kind regards,

      Rudy.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.