cancel
Showing results for 
Search instead for 
Did you mean: 

how can i hide elements of a view?

Former Member
0 Kudos

Hi,, i've got a question about, how can i hide an element of a view?, this element colud be a group, a label, an input field, any element that i can put in the view layout.

My view has an ALV, an inputfield and a Table with a button, so when i click on a line of the alv, it shows data in the table and in the inputfield, and when i click on the button of the table, i want to hide the table and the inputfield, until i clik on the alv again to make appear the table and the inputfield.

how can i hide those element?,,,,,,,,thanks

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Luis,

I have not much to add, mahesh's ans is preety apt, but ya' i would like to mention some of the details in this particular requirement.

- Create a attribute in a node by name of 'Visibility' and give it a type as 'wdy_boolean'. Please check that you have not given any DDIC type to the structure, coz if you have framework would not allow you to add any other attribute that does not belong to the structure you have mentioned.

- now your UI Elements Table and Inputfield has got a property has 'Visibilty', bind that property of both the UI Elements to the Attribute "Visibility".Also if you want to give some default value you can, in the attribute, depending on your requirement ie wheather you want to display them initially or not.

- Now on lead select of the table you can call a function module in which you can write the code Mahesh has mentioned. This table is the one through which you are displaying the data in ALV.

Hope this helps.

Cheers!

Ashish

Former Member
0 Kudos

Hi Luis Garcia,

It can be done easily by <b>context binding</b> the visibility property of the table and input field UI element to a node attribute whose type would be WDY_BOOLEAN.

1. Initially the node attributes default value would be 'X'.

2. When you click the button in the ALV, in the event handler of that button change the binded node attribute value to ' '.

3. When on lead selection of the table again change the binded node attribute field value to 'X'.

4. Below is the sample code to read the binded node attribute and toggle the visiblity attribute to 'X' if it is ' ' and vice versa.


  data:
    Node_If                             type ref to If_Wd_Context_Node,
    Elem_If                             type ref to If_Wd_Context_Element,
    Stru_If                             type If_Main=>Element_If ,
    Item_VISIBILITY                     like Stru_If-VISIBILITY.
* navigate from <CONTEXT> to <IF> via lead selection
  Node_If = wd_Context->get_Child_Node( Name = IF_MAIN=>wdctx_If ).

* get element via lead selection
  Elem_If = Node_If->get_Element(  ).

* get single attribute
  Elem_If->get_Attribute(
    exporting
      Name =  `VISIBILITY`
    importing
      Value = Item_Visibility ).


if Item_visibility is initial.
item_visibility = 'X'.
else.
item_visibility = ' '.
endif.


  Elem_If->set_Attribute(
      Name =  `VISIBILITY`
      Value = Item_Visibility ).

endmethod.

Hope it helps.

Regards,

Maheswaran.B

Former Member
0 Kudos

Hi Luis,

Each element on the screen has a visibility property. I cannot recall the name but it should be a good starting point for you. So if you need to hide it from the user you would have set it accordingly. Also, each UI element in WD has a corresponding class that you can check for attributes.

Thanks and I hope this helps.

Georgy