on 09-25-2008 11:51 AM
Hi,
in my application there are two views. On the frist view there are two inputfields "from date"
and "to date". Depending on these two dates i want to build a table on the second view wich
contains one column for every day in the selected period. How could I create these columns
dynamically with the corresponding date in the header of the column?
Regards,
Mario
Hi Uday,
great example, thank you. Is It possible to declarate the dynamic columns as input fields and bind them to the context? You can give me another code snippet??
Regards,
Mario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can dynamically create table columns with an InputField UI-Element as cell editor.
Use method CL_WD_INPUT_FIELD=>NEW_INPUT_FIELD. The context path is set via the import parameter BIND_VALUE.
The context path is a concatenation of the node names in the context hierarchy, separated by a dot, e.g. 'NODEMAIN.NODE'.
Regards, Silke
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mario,
I have created a dropdown with the names of all the months and then displayed a table below it. Am creating the table columns dynamically depending up on the month selected by the user. I guess that it should help make you understand the logic.
Regards,
Uday
I had created 2 context nodes.
Node: DROPDOWN is used to store the dropdown values (Jan, Feb...)
Node: TABLE is a dummy node with no attributes used for binding to the table
Declare a variable (say GR_TABLE) of type CL_WD_TABLE in attributes tab of your view. Then in the wddomodifyview method just save the reference of your table UI element into this variable. (NOTE: TABLE is the name which I have given for my TABLE UI element in the view)
method WDDOMODIFYVIEW .
check first_time = abap_true.
wd_this->gr_table ?= view->get_element( id = 'TABLE' ).
endmethod.
Now coming to the main part of creating columns dynamically as per the selected month. I have put a pushbutton beside my DropDownByIndex which the user has to select after making a selction. This button triggers the action ONFETCH. We make use of the 2 classes CL_WD_TABLE & CL_WD_TABLE_COLUMN & the methods REMOVE_ALL_COLUMNS & ADD_COLUMN methods for achieving the desired output. But Manjunath my coding does not include creation of binding for the created columns. You will have to try code that yourself. You can find the necessary methods by going through CL_WD_TABLE & CL_WD_TABLE_COLUMN. Hope that this is helpful for you.
Regards,
Uday
Fill the respective month names in order to appear in the DropDownByIndex.
Coding inside the WDDOINIT method:
METHOD wddoinit .
DATA: lv_node TYPE REF TO if_wd_context_node,
lt_dropdown TYPE ig_componentcontroller=>elements_DROPDOWN,
wa_dropdown TYPE ig_componentcontroller=>element_DROPDOWN.
wa_dropdown-values = 'January'.
append wa_dropdown to lt_dropdown.
wa_dropdown-values = 'February'.
append wa_dropdown to lt_dropdown.
-
-
-
-
lv_node = wd_context->get_child_node( name = ig_componentcontroller=>wdctx_dropdown ).
lv_node->bind_table( new_items = lt_dropdown ).
ENDMETHOD.
Coding for ONFETCH action triggered by pushbutton:
METHOD ONACTIONONFETCH .
DATA: lv_node TYPE REF TO if_wd_context_node,
lt_dropdown TYPE if_main=>elements_dropdown,
wa_dropdown TYPE if_main=>element_dropdown,
lead_selection_index TYPE i,
lr_column type ref to cl_wd_table_column.
wd_this->gr_table->REMOVE_ALL_COLUMNS( ).
lv_node = wd_context->get_child_node( name = 'DROPDOWN' ).
CALL METHOD lv_node->get_static_attributes_table
IMPORTING
table = lt_dropdown.
lead_selection_index = lv_node->get_lead_selection_index( ).
READ TABLE lt_dropdown INTO wa_dropdown INDEX lead_selection_index.
CASE lead_selection_index.
WHEN '9' or '11' or '4' or '6'. "Sep, Nov, April, June
do 30 times.
lr_column = cl_wd_table_column=>new_table_column( ).
wd_this->gr_table->add_column( index = sy-index
the_column = lr_column ).
enddo.
when '10' or '12' or '1' or '3' or '5' or '7'. " Oct, Dec, Jan, Mar, May, July, Aug
do 31 times.
lr_column = cl_wd_table_column=>new_table_column( ).
wd_this->gr_table->add_column( index = sy-index
the_column = lr_column ).
enddo.
when others. " Feb
do 29 times.
lr_column = cl_wd_table_column=>new_table_column( ).
wd_this->gr_table->add_column( index = sy-index
the_column = lr_column ).
enddo.
ENDCASE.
ENDMETHOD.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.