on 11-12-2007 6:36 AM
I have a requirement wherein i have to read a database table and based on the number of entries in this table, i have to add that many checkboxes on the webdynpro view at runtime.
Please let me know how this can be achieved.
regards,
Priyank
Here is the code
DATA: lr_root_node TYPE REF TO if_wd_view_element,
lr_container TYPE REF TO cl_wd_uielement_container,
lr_context_node_info TYPE REF TO if_wd_context_node_info,
st_contxt_attr TYPE wdr_context_attribute_info,
lr_check_box TYPE REF TO cl_wd_checkbox.
IF first_time = abap_true.
CALL METHOD view->get_element
EXPORTING
id = 'ROOTUIELEMENTCONTAINER'
RECEIVING
element = lr_root_node.
lr_container ?= lr_root_node.
<b>Get ref of node</b>
lr_context_node_info = wd_context->get_node_info( ).
<b>Create attributes</b>
st_contxt_attr-name = 'A'.
st_contxt_attr-type_name = 'WDY_BOOLEAN'.
lr_context_node_info->add_attribute( st_contxt_attr ).
st_contxt_attr-name = 'B'.
st_contxt_attr-type_name = 'WDY_BOOLEAN'.
lr_context_node_info->add_attribute( st_contxt_attr ).
st_contxt_attr-name = 'C'.
st_contxt_attr-type_name = 'WDY_BOOLEAN'.
lr_context_node_info->add_attribute( st_contxt_attr ).
<b>Create checkboxes</b>
CALL METHOD cl_wd_checkbox=>new_checkbox
RECEIVING
control = lr_check_box.
<b> Bind Checked mandatory parameter</b>
lr_check_box->bind_checked( path = 'A' ). -----> this is the first attribute. In the same
fashion you can add remaining
attributes
lr_check_box->set_text( value = '1st check box').
cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_check_box ).
lr_container->add_child( lr_check_box ).
ENDIF.
You can keep the reference <b>lr_check_box</b> in the attributes tabs for you to later check which checkbox was checked using method GET_CHECKED of class CL_WD_CHECKBOX.
<b>No context node or attributes are required to be created. It is created dynamically as shown above. Copy the code as it is in WDDOMODIFYVIEW of the view controller.
To register the on ON_TOGGLE EVENT, in the importing parameter of the following code
CALL METHOD cl_wd_checkbox=>new_checkbox
exporting
ON_TOGGLE = 'TEST1'
RECEIVING
control = lr_check_box.
TEST1 is the action method which is required to be created in the Action tab. Then in event handler method you can write you desired code also. Do it for all the check boxes that you have added if required.
</b>
Regards,
Sridhar Karra.
Please reward points if answer is satisfactory!!!
Message was edited by:
Sridhar Karra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, as is the main code:
loop at lt_valuehelp into ls_valuehelp.
lo_new_node_elem = lo_new_node->create_element( ).
lo_new_node->bind_element(
exporting
new_item = lo_new_node_elem
set_initial_elements = abap_false
index = lv_index ).
lo_new_node_elem->set_attribute(
value = ls_valuehelp-key_id
name = lv_key_attr_name ).
lo_new_node_elem->set_attribute(
value = ls_valuehelp-value
name = lv_texts_prop_attr_name ).
lo_new_node_elem->set_attribute(
value = is_sme_information-sm_element_id
name = lv_sme_id_attr_name ).
lo_new_node_elem->set_attribute(
value = is_sme_information-layout_tag
name = lv_sme_type_attr_name ).
lo_new_node->set_selected(
flag = ' '
index = lv_index ).
lv_index = lv_index + 1.
clear: lo_new_node_elem,
ls_valuehelp.
endloop.
cl_wd_checkbox_group=>new_checkbox_group(
exporting
bind_texts = lv_texts_prop_attr_path "binding path string
id = lv_ui_element_id
receiving
control = lo_check_box_group ).
cl_wd_matrix_data=>new_matrix_data(
exporting
element = lo_check_box_group
receiving
control = lo_layout_data ).
container->add_child(
exporting
the_child = lo_check_box_group ).
Regards!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi priyank...
you can write the codings for it in your modifyview.
consider you are having an input field and the number of check boxes depend on the number entered in the input field.
in that case...
you can make use of the class cl_wd_checkbox inside a loop.
this has to be written in your modify view.
--regards,
alex b justin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Priyank,
You can refer the link <a href="http://help.sap.com/saphelp_nw70/helpdata/en/94/29984197eb2e7be10000000a1550b0/frameset.htm">Dynamic Programming</a> for information on how to add UI Elements dynamically.
Thanks and Regards,
Saravana. S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
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.