on 02-17-2011 10:40 AM
Hello,
I need to draw check boxes in my view dynamically depending on an sql query result.
The problem is how to get the current view to use its method get_element.
My source code is below
thanks.
<Code>
LOOP AT lt_benef_list_node INTO ls_benef_list_node.
*Create Node
lr_view_controller = wd_this->wd_get_api( ).
CALL METHOD view->get_element EXPORTING id = 'OPTIONS_CTR' RECEIVING element = lr_root_node.
lr_container ?= lr_root_node.
lr_context_node_info = wd_context->get_node_info( ).
CONCATENATE 'Check_' counter into AttributID.
MOVE ls_benef_list_node-nodenameext TO AttributTxt.
st_contxt_attr-name = AttributID.
st_contxt_attr-type_name = 'WDY_BOOLEAN'.
*Create CheckBox
CALL METHOD cl_wd_checkbox=>new_checkbox
RECEIVING
control = lr_check_box.
*Bind checkbox to Node
lr_check_box->bind_checked( path = AttributID ).
lr_check_box->set_text( value = AttributTxt ).
cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_check_box ).
lr_container->add_child( lr_check_box ).
AttributID = ''.
ENDLOOP.
</Code>
done by my self.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI
view is available in wddomodify generally.
you can make it availabale in all the methods by creating an attriubte of type if_wd_view.
say its name as view1.
then in wddomodify
set it in view1
wd_this->view1 = view.
and use it in any method by fetching it
data view1 type ref to if_Wd_view.
view1 = wd_this->view1.
then use get element
CALL METHOD view1->get_element
EXPORTING
id = 'OPTIONS_CTR'
RECEIVING
element = lr_root_node.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I switched to on modify and now i can get the "view".
But now i have an error when i try to use bind_cheked it tels me that 'atributID' is not compatible with formal parameter path.
I cheked the method and the type of the path parameter is string as my atributID.
lr_checkbox->bind_checked( PATH = AttributID ).
Edited by: Achref zaidi on Feb 17, 2011 12:09 PM
This my code.
I still get that error:
LOOP AT lt_benef_list_node INTO ls_benef_list_node.
*Create Node
lr_view_controller = wd_this->wd_get_api( ).
CALL METHOD view->get_element
EXPORTING
id = 'OPTIONS_CTR'
RECEIVING
element = lr_root_node.
lr_container ?= lr_root_node.
lr_context_node_info = wd_context->get_node_info( ).
move counter to counters.
CONCATENATE 'OPTIONS_NODE.Check_' counters into AttributID.
MOVE ls_benef_list_node-nodenameext TO AttributTxt.
st_contxt_attr-name = AttributID.
st_contxt_attr-type_name = 'WDY_BOOLEAN'.
*Create CheckBox
CALL METHOD cl_wd_checkbox=>new_checkbox
RECEIVING
control = lr_checkbox.
*Bind checkbox to Node
lr_checkbox->bind_checked( PATH = AttributID ).
lr_checkbox->set_text( value = AttributTxt ).
cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_checkbox ).
lr_container->add_child( lr_checkbox ).
AttributID = ''.
ENDLOOP.
Edited by: Achref zaidi on Feb 17, 2011 1:09 PM
Try this
LOOP AT lt_benef_list_node INTO ls_benef_list_node.
*Create Node
lr_view_controller = wd_this->wd_get_api( ).
CALL METHOD view->get_element
EXPORTING
id = 'OPTIONS_CTR'
RECEIVING
element = lr_root_node.
lr_container ?= lr_root_node.
lr_context_node_info = wd_context->get_node_info( ).
move counter to counters.
CONCATENATE 'OPTIONS_NODE.CHECK_' counters into AttributID.
CONDENSE AttributID.
MOVE ls_benef_list_node-nodenameext TO AttributTxt.
st_contxt_attr-name = AttributID.
st_contxt_attr-type_name = 'WDY_BOOLEAN'.
*Create CheckBox
CALL METHOD cl_wd_checkbox=>new_checkbox
RECEIVING
control = lr_checkbox.
*Bind checkbox to Node
lr_checkbox->bind_checked( PATH = AttributID ).
lr_checkbox->set_text( value = AttributTxt ).
cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_checkbox ).
lr_container->add_child( lr_checkbox ).
AttributID = ''.
>view is available in wddomodify generally.
>you can make it availabale in all the methods by creating an attriubte of type if_wd_view.
>say its name as view1.
This is extremely bad advice and you should never actually do this. Accessing the view in any other step of the phase model than WDDOMODIFYVIEW can result in unpredicatble behavior and is not supported by SAP.
Instead set flags within the other event handlers and then evaluate these flags within the WDDOMODIFYVIEW.
>
> >view is available in wddomodify generally.
> >you can make it availabale in all the methods by creating an attriubte of type if_wd_view.
> >say its name as view1.
>
> This is extremely bad advice and you should never actually do this. Accessing the view in any other step of the phase model than WDDOMODIFYVIEW can result in unpredicatble behavior and is not supported by SAP.
>
> Instead set flags within the other event handlers and then evaluate these flags within the WDDOMODIFYVIEW.
OOPs is it so.
actually i also havenot used it anywher.
thanks for pointing out thomas.
thanks
Hi ,
This kind of code can be written in the WDDOMODIFY method of the view.
In this method it is available.
Thanks,
Aditya.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
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.