on 05-22-2009 2:47 PM
Hello,
can I hide or show uielements depending on a customertable. In this custumer table
the uielements have an additional columns as status for display or hide.
Regards
ertas
Hi,
Bind the UI elements visibility property with the attribute of type wdui_visibility
Read that visibility coloum of table and on the basis of their status set the visibility of UI elements visible or In-Visible.
To make it visible set attribute as 02
To make it In-visible set attribute as 01
I hope it helps.
Regards,
Rohit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
uday thousand thanks.
I will check it up. I have rigth now a telco. If I am ready I give you a feedback
Regards
ertas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
dear rohit I dont get the error message that was the solution for dunping.
But the next problem is I get all the elements displayed.
e.g. is field name invisible it should not be displayed. What can the reason be for that ?
Maybe is abap_false not the right command for NONE
lo_el_visibility->set_attribute(
name = `VISIBLE`
value = abap_false ).
endif.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you are looking to hide an entire column, you will have to create a separate attribute type boolean.
( not under the same node ).
Now bind the visible property of the column with this attribute and then based on your condtion pass abap_true/ abap_false.
data: l_elem type ref to if_wd_context_element.
l_elem = wd_context->get_element( ).
l_elem->SET_ATTRIBUTE ( EXPORTING NAME = 'VISIBILE' VALUE = abap_false ).
Regards,
Radhika.
Edited by: Radhika Vadher on May 25, 2009 2:46 PM
Dear Gentlemen,
this is the current code and it is sitll not working.
I took the type wdy_boolean. Everything remains the same
method WDDOINIT .
data wa type ZPERSCONFIG.
DATA lo_nd_visibility TYPE REF TO if_wd_context_node.
DATA lo_el_visibility TYPE REF TO if_wd_context_element.
DATA ls_visibility TYPE wd_this->element_visibility.
DATA lv_visible TYPE wd_this->element_visibility-visible.
select * from ZPERSCONFIG into table wd_this->TCONF.
lo_nd_visibility = wd_context->get_child_node( name = wd_this->wdctx_visibility ).
* get element via lead selection
lo_el_visibility = lo_nd_visibility->get_element( ).
LOOP AT wd_this->TCONF INTO wa.
IF wa-SICHTBAR = 'X'.
* set single attribute
lo_el_visibility->set_attribute(
name = `VISIBLE`
value = abap_true ).
else.
* set single attribute
lo_el_visibility->set_attribute(
name = `VISIBLE`
value = abap_false ).
endif.
ENDLOOP.
DATA: lt_kteile TYPE if_main=>elements_pers,
wa_kteile TYPE if_main=>element_pers,
lv TYPE REF TO if_wd_context_node.
lv = wd_context->get_child_node( name = 'PERS' ).
lv->bind_table( new_items = lt_kteile ).
endmethod.
Edited by: Ilhan Ertas on May 25, 2009 11:35 AM
Hi Ertas,
Suppose you are showing 4 columns (CARRID, CONNID, FLDATE & PRICE) & have these then you should have 4 attributes under the node SFLIGHT. Then in order to control the visibility of these 4 columns you need to have another 4 attributes of type WDUI_VISIBILITY ( say V1, V2, V3 & V4) & these should be present under some other context node say NODE1. Within the layout tab go to the column of each table & bind its visibility attribute to the corresponding V1..V4 attributes.
I guess that you have bound all your columns to the same context attribute so with this coding you would end up either displaying all the columns or not displaying all of the columns. You need to have separate attributes to bind for each column. That way you would be able to control the visibility properly. In your case the last entry in wd_this->TCONF must be satisfying wa-SICHTBAR = 'X' coz of which you would end up displaying all the columns. Just try check it out in debugging mode. If you make the value of wa-SICHTBAR something other than 'X' for the last entry you should end up with no columns being displayed for you...
Regards,
Uday
Uday youare really an expert.
Indeed I
have bound all my columns to the same context attribute so with this coding I am ending up either displaying all the columns or not displaying all of the columns.
You are saying:
You need to have separate attributes to bind for each column.
How must I change the above coding in this case if I have seperate colums.
Regards
ertas
Hi Ertas,
You would just be creating additional attributes of the same type WDUI_VISIBILITY. That's all. The rest of the logic & approach remains the same. Suppose you have 4 columns COL1..COL4 & you have corresponding attributes ATTR1..ATTR4 (of type WDUI_VISIBILITY). You would bind the visibility of COL1 to ATTR2, COL2 to ATTR2 and so on...
So now when you read the ZPERSCONFIG table you would get both the name of the field & its desired visibility. So suppose you get the field as COL1 & its visibility as none then you need to set the attribute ATTR1 using the same logic of yours. If you get the field as COL2 then you set the ATTR2 and so on.....
I hope that I could convey you the logic.
Regards,
Uday
Hi Ertas,
Ur welcome! The coding would come to something like this... Suppose ZPERSCONFIG has a field by name fieldname which holds the name of the ui element that you want to control then you have a code similar to the one shown below. [ Am sorry if it does contain any syntax/typing mistakes as its just 30 minutes before I get to run home! ]
Regards,
Uday
LOOP AT wd_this->TCONF INTO wa.
case wa-fieldname.
when 'FIELD1'.
IF wa-SICHTBAR = 'X'.
* set single attribute
lo_el_visibility->set_attribute(
name = `ATTR1`
value = abap_true ).
else.
* set single attribute
lo_el_visibility->set_attribute(
name = `ATTR1`
value = abap_false ).
endif.
when 'FIELD2'.
IF wa-SICHTBAR = 'X'.
* set single attribute
lo_el_visibility->set_attribute(
name = `ATTR2`
value = abap_true ).
else.
* set single attribute
lo_el_visibility->set_attribute(
name = `ATTR2`
value = abap_false ).
endif.
endcase.
ENDLOOP.
hi I have tried it this the result
this is not initial
lo_nd_visibility = wd_context->get_child_node( name = wd_this->wdctx_visibility ).
this initial in the debugger
lo_el_visibility = lo_nd_visibility->get_element( ).
right here the error message
Access via 'NULL' object reference not possible.
* set single attribute
lo_el_visibility->set_attribute(
name = `VISIBLE`
value = abap_true ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Uday I have changed but I am getting still the same error message
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I get this error message:
Node MAIN.1.VISIBILITY does not contain any elements
There are two ddic tables
ZPERSCONFIG contains two fields =fieldname and visiblilty (yes or no)
ZPERS coantains data about person
I have create a context node VISIBILITY with cardinality 0:1 with a attribute VISIBLE of type CHAR1.
Populate this context node attribute with 'X' OR space based your table entry.
method WDDOINIT .
data wa type ZPERSCONFIG.
data lr_node type ref to if_wd_context_node.
select * from ZPERSCONFIG into table wd_this->TCONF.
lr_node = WD_CONTEXT->get_child_node( name = 'VISIBILITY' ).
LOOP AT wd_this->TCONF INTO wa.
IF wa-SICHTBAR = 'X'.
lr_node->SET_ATTRIBUTE( EXPORTING NAME = 'VISIBLE' VALUE = abap_true ).
else.
lr_node->SET_ATTRIBUTE( EXPORTING NAME = 'VISIBLE' VALUE = abap_false ).
endif.
ENDLOOP.
DATA: lt_kteile TYPE if_main=>elements_pers,
wa_kteile TYPE if_main=>element_pers,
lv TYPE REF TO if_wd_context_node.
lv = wd_context->get_child_node( name = 'PERS' ).
lv->bind_table( new_items = lt_kteile ).
endmethod.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try Using the Your code in the following way.
method WDDOINIT .
data wa type ZPERSCONFIG.
DATA lo_nd_visibility TYPE REF TO if_wd_context_node.
DATA lo_el_visibility TYPE REF TO if_wd_context_element.
DATA ls_visibility TYPE wd_this->element_visibility.
DATA lv_visible TYPE wd_this->element_visibility-visible.
select * from ZPERSCONFIG into table wd_this->TCONF.
* navigate from <CONTEXT> to <VISIBILITY> via lead selection
lo_nd_visibility = wd_context->get_child_node( name = wd_this->wdctx_visibility ).
* get element via lead selection
lo_el_visibility = lo_nd_visibility->get_element( ).
LOOP AT wd_this->TCONF INTO wa.
IF wa-SICHTBAR = 'X'.
* set single attribute
lo_el_visibility->set_attribute(
name = `VISIBLE`
value = abap_true ).
else.
* set single attribute
lo_el_visibility->set_attribute(
name = `VISIBLE`
value = abap_false ).
endif.
ENDLOOP.
DATA: lt_kteile TYPE if_main=>elements_pers,
wa_kteile TYPE if_main=>element_pers,
lv TYPE REF TO if_wd_context_node.
lv = wd_context->get_child_node( name = 'PERS' ).
lv->bind_table( new_items = lt_kteile ).
endmethod.
I hope it helps.
Regards,
Rohit
Create a context node VISIBILITY with cardinality 0:1 with a attribute VISIBLE of type CHAR1.
populate this context node attribute with 'X' OR space based your table entry.
now bind the VISIBLE attribute to the UI element for which you want to make it hide or visible.
now populate the VISIBLE with 'X' or space by calling the method of the node
VISIBILITY->SET_ATTRIBUTE ( EXPORTING NAME = 'VISIBILE' VALUE = VISIBLE ).
Regards,
Anil kumar G
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do you have an code example for me ?
Kindly Regards
ertas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ertas,
Yes , you can hide or show UI elements based an any attribute value or a database table field value.
Basically you can set any attribute value by binding the property of that particular to any context node that you have created in your view. Obviously that particular context node you must be fetching the data from one of the database table you want. so in runtime based on the value in the field the visibility varies.
the property VISIBLE of the UI element you need to bound.
Regards,
Anil kumar G
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.