1 Reply Latest reply: Feb 28, 2012 8:38 AM by Harshith Reddy RSS

Web Dynpro: Dynamic table with multiple column groups.

Madhavan R
Currently Being Moderated

Hello Experts,

 

My requirement is to create a table dynamically with multiple column groups shown as below.

-


column grp3

-


columngrp2

columngrp2

-


columngrp1

columngrp1

-


table

 

 

Now, I need to display column group3 as a checkbox and I need to set link-to-action for column group1 & 2.

 

Please help me out to achieve these function. Thanks in Advance.

 

Madhavan.R

  • Re: Web Dynpro: Dynamic table with multiple column groups.
    Harshith Reddy
    Currently Being Moderated

    Hi,

     

        The below code creates a Main Group and under which has Goup1 under which you have two columns

        with input fields. Similarly you can create columns with check box or link to action.

     

        Write the following into wddomodify of your view.

        

        

       data lr_cont type ref to cl_wd_uielement_container.
      data lr_input TYPE REF TO cl_wd_input_field.
      data lr_input1 TYPE REF TO cl_wd_input_field.
      data lr_table type REF TO cl_wd_table.
      DATA lr_table_column TYPE REF TO cl_wd_table_column.
      DATA lr_table_column1 TYPE REF TO cl_wd_table_column.
      DATA lr_column_group TYPE REF TO cl_wd_table_column_group.
      data lr_cap TYPE REF TO cl_wd_caption.
      data lr_cap1 TYPE REF TO cl_wd_caption.
      data lr_cap2 TYPE REF TO cl_wd_caption.
      DATA lr_caption TYPE REF TO cl_wd_caption.
      data lr_group type REF TO cl_wd_table_column_group.
      data lr_mgroup type REF TO cl_wd_table_column_group.
    
      lr_cont ?= VIEW->GET_ELEMENT( 'ROOTUIELEMENTCONTAINER' ).
    
      CALL METHOD CL_WD_INPUT_FIELD=>NEW_INPUT_FIELD
        RECEIVING
          CONTROL             = lr_input.
      lr_input->bind_value( 'NODE.ATTR1' ).       "Context path of the attribute to be displayed
      data : lr_flow TYPE REF TO cl_wd_flow_data.
    CALL METHOD CL_WD_FLOW_DATA=>NEW_FLOW_DATA
      EXPORTING
        ELEMENT     = lr_input
      RECEIVING
        CONTROL     = lr_flow.
    lr_input->set_layout_data( lr_flow ).
    CALL METHOD CL_WD_CAPTION=>NEW_CAPTION
      EXPORTING
        TEXT                = 'ATTR1'           "column header for attr1
      RECEIVING
        CONTROL             = lr_cap.
    CALL METHOD CL_WD_TABLE_COLUMN=>NEW_TABLE_COLUMN
      RECEIVING
        CONTROL  = lr_table_column.
    lr_table_column->set_table_cell_editor( lr_input ).
    lr_table_column->set_header( lr_cap ).
    
    
      CALL METHOD CL_WD_INPUT_FIELD=>NEW_INPUT_FIELD
        RECEIVING
          CONTROL             = lr_input1.
      lr_input1->bind_value( 'NODE.ATTR2' ).         "Context path of attribute to be displayed
      data : lr_flow1 TYPE REF TO cl_wd_flow_data.
    CALL METHOD CL_WD_FLOW_DATA=>NEW_FLOW_DATA
      EXPORTING
        ELEMENT     = lr_input1
      RECEIVING
        CONTROL     = lr_flow1.
    lr_input1->set_layout_data( lr_flow1 ).
    CALL METHOD CL_WD_CAPTION=>NEW_CAPTION
      EXPORTING
        TEXT                = 'ATTR2'          "column header of attr2
      RECEIVING
        CONTROL             = lr_cap1.
    CALL METHOD CL_WD_TABLE_COLUMN=>NEW_TABLE_COLUMN
      RECEIVING
        CONTROL  = lr_table_column1.
    lr_table_column1->set_table_cell_editor( lr_input1 ).
    lr_table_column1->set_header( lr_cap1 ).
    
    
    CALL METHOD CL_WD_TABLE_COLUMN_GROUP=>NEW_TABLE_COLUMN_GROUP
      RECEIVING
        CONTROL  = lr_group.
    CALL METHOD CL_WD_CAPTION=>NEW_CAPTION
      EXPORTING
        TEXT                = 'GROUP1'                "header for column group
      RECEIVING
        CONTROL             = lr_caption.
    lr_group->set_header( lr_caption ).
    lr_group->add_column( lr_table_column ).
    lr_group->add_column( lr_table_column1 ).
    
    
    CALL METHOD CL_WD_TABLE_COLUMN_GROUP=>NEW_TABLE_COLUMN_GROUP
      RECEIVING
        CONTROL  = lr_mgroup.
    CALL METHOD CL_WD_CAPTION=>NEW_CAPTION
      EXPORTING
        TEXT                = 'MAIN GROUP'        "header for main column group
      RECEIVING
        CONTROL             = lr_cap2.
    lr_mgroup->set_header( lr_cap2 ).
    lr_mgroup->add_column( lr_group ).
    
    CALL METHOD CL_WD_TABLE=>NEW_TABLE
      EXPORTING
        BIND_DATA_SOURCE              = 'NODE'
      RECEIVING
        CONTROL                       = lr_table.
    lr_table->set_layout_data( lr_flow ).
    lr_table->add_grouped_column( lr_mgroup ).
    
    lr_cont->add_child( lr_table ).
      

     

Actions