cancel
Showing results for 
Search instead for 
Did you mean: 

to show table on a click of a button

Former Member
0 Kudos
102

hi,

i need to first hide the table and then on clicking a button it should be displayed, button and table are in the same view.please tell which method to be used and how to connect the button to table.i have crated the action also.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Create an attribute of type com.sap.ide.webdynpro.uielementdefinitions.Visibility

Map this attribute to the visible property of the table.

Initially set this to WDVisibility.NONE and inside the action handler set this to WDVisibility.VISIBLE.

Ex:

If your attribute name is TableVisibility then

In the init

wdContext.currentContextElement().setTableVisibility(WDVisibility.NONE);

In the button action Handler

wdContext.currentContextElement().setTableVisibility(WDVisibility.VISIBLE);

Regards

Ayyapparaj

Former Member
0 Kudos

thanks a lot u r answer helped to solve the problem.

Answers (1)

Answers (1)

former_member485701
Active Participant
0 Kudos

Hi Nisha,

Create button and Table say "TableID" in the view

(1) Keep a global boolean variable say "showTable".

(2) in the action of button click set this variable as true.

(3) Now in wdDoModifyView method:

IWDTable table=(IWDTable) view.getElement("TableID") ;

if(showTable){

table.setVisible(WDVisibility.VISIBLE);

}else{

table.setVisible(WDVisibility.NONE);

}

Now your problem is solved.

Regards,

Praveen

Former Member
0 Kudos

By "global", you mean static, yes? Then this is bad advice.

Armin

former_member485701
Active Participant
0 Kudos

Hi Armin,

I accept it, it's a bit misleading. At the beginner's perspective it's not good. But with

Global, the sense was :- you can create a boolean context variable, which value you can set on the action of button.

Regards,

Praveen

Former Member
0 Kudos

Hi,

To toggle I guess this should be a better approach.

WDVisibility currentStatus = wdContext.currentContextElement().getVisibility() //Visibility is a context attribute created of type WDVisibility mentioned above

if ( currentStatus.equals(WDVisibility.VISIBLE) )

wdContext.currentContextElement().setVisibility(WDVisibility.NONE);

else

wdContext.currentContextElement().setVisibility(WDVisibility.VISIBLE);

Dont forget to initialize the context variable to a default value either NONE/VISIBLE.

Regards

Ayyapparaj

Former Member
0 Kudos

It has nothing to do with "beginners perspective". Using a static variable here will break your code because it is not thread-safe. The data binding solution is the way to go.

Armin

Former Member
0 Kudos

It is safe here to compare using "==".

Armin