cancel
Showing results for 
Search instead for 
Did you mean: 

hide or show uielements

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member40425
Contributor
0 Kudos

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

Answers (8)

Answers (8)

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

Hi Ertas,

Are looking for hiding an entire column ?

Radhika.

Former Member
0 Kudos

yes.

Suppose there are 10 columns. Some of them are visible and some of them invisble

I do populate this context node attribute with 'X' OR space based your table entry ZPERSCONFIG .

But t doesn' take effect

Edited by: Ilhan Ertas on May 25, 2009 11:12 AM

Former Member
0 Kudos

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

former_member40425
Contributor
0 Kudos

Hi,

Change the type of attribute visible from char1 to wdy_boolean.

Regards,

Rohit

Former Member
0 Kudos

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

Former Member
0 Kudos

I hope you have binded the visible property of the column with the attribute 'VISIBLE'.

uday_gubbala2
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

uday_gubbala2
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Uday I will check it out and i will give you feedback.

If it works I will set it as solved

Thank you very much for your expert knowledge hints

uday_gubbala2
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

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 ).

former_member40425
Contributor
0 Kudos

Hi,

try with Changing the cardinality to 1:1 or 1:N.

Regards,

Rohit

Former Member
0 Kudos

hi Uday I have changed but I am getting still the same error message

Former Member
0 Kudos

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.

uday_gubbala2
Active Contributor
0 Kudos

Hi Ertas,

Try changing the cardinality of your VISIBILITY node to 0..n

Regards,

Uday

former_member40425
Contributor
0 Kudos

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

former_member230839
Participant
0 Kudos

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

Former Member
0 Kudos

Anil kumar G thanks a lot for your help.

I get with this message a systax error.

VISIBILITY->SET_ATTRIBUTE ( EXPORTING NAME = 'VISIBILE' VALUE = VISIBLE ).

How is the correct syntax to relate the node and then to its attribute

My Node:

RADELLL

Attribut

Status

Regards,

Former Member
0 Kudos

Hi,

Your attribute visible should be type boolean,

Use this code,

VISIBILITY->SET_ATTRIBUTE ( EXPORTING NAME = 'VISIBILE' VALUE = abap_true ).

Radhika.

Former Member
0 Kudos

Do you have an code example for me ?

Kindly Regards

ertas

former_member40425
Contributor
0 Kudos

Can you give data of one row of your custom table.

So that i can come to which all fields are there in the table and on which field visibility status is dependent.

Regards,

Rohit

former_member230839
Participant
0 Kudos

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