cancel
Showing results for 
Search instead for 
Did you mean: 

Help to hide subform if its table is empty. Using Javascript.

Former Member
0 Kudos

I have the following structure:

[http://i47.tinypic.com/2q88vuw.jpg|http://i47.tinypic.com/2q88vuw.jpg]

I tried everything I could think of to hide the subform but without success.

Can anyone help me with some javascript code that would work?

Thanks,

Paul

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Paul,

I assumed there is a main subform to contain FREIGHT subform, OTHERCHARGES subform, and etc.

Lets name the main subform as MAIN.

Please change the MAIN subform to have Flowed type, so each when FREIGHT is being hided, the subsequent subform can flow upwards instead of leaving a blank.

Object -> Subform -> Content = "Flowed".

code to hide the subform

xfa.form.data.MAIN.FERIGHT.presence = "hidden"; 

Hope this helps.

regards,

Xiang Li

Former Member
0 Kudos

Hi Xiang Li,

Thanks for the reply, however that is not my issue.

I am able to hide the subform using code:

this.presence = "hidden";

(code on the subform)

My issue is formulating the condition to hide the subform when the table inside of it is empty.

i.e.


if ( this.Freight_data.FREIGHT ... == null ) {
 this.presence = "hidden";
}

I tried

 if ( this.Freight_data.FREIGHT.isNull ) 
 if ( this.Freight_data.FREIGHT.DATA.isNull ) 

etc.

none work.

Former Member
0 Kudos

Hi

Assuming you are having the subforms in this order : PAGE1 - > Subform1(containing table FREIGHT)->other subforms for header,footer etc...

1) Layout of PAGE1 and Subform1should be 'Flowed'.

2) In Pagination tab of Subform1, Place = "Following Previous"

3) Write the below code in the initialize event of table.

-


PAGE1.Subform1.FRIEGHT::initialize: - (JavaScript, client) -


if (PAGE1.Subform1.FRIEGHT[0] == null )

{

PAGE1.Subform1.FRIEGHT.presence = "hidden" ;

}

-When you hide the table, subform will hide by itself.

Regards

Deepa.

Former Member
0 Kudos

Assuming you are having the subforms in this order : PAGE1 - > Subform1(containing table FREIGHT)->other subforms for header,footer etc...

1) Layout of PAGE1 and Subform1should be 'Flowed'.

2) In Pagination tab of Subform1, Place = "Following Previous"

3) Write the below code in the initialize event of table.

PAGE1.Subform1.FRIEGHT::initialize: - (JavaScript, client)

if (PAGE1.Subform1.FRIEGHT[0] == null ) { PAGE1.Subform1.FRIEGHT.presence = "hidden" ; }

-When you hide the table, subform will hide by itself.

Doesn't work.

My header is not part of the table. It is part of the subform containing the table.

I need to have it work like that, as I have other similar sections that use tables but are formatted as subforms.

Former Member
0 Kudos

I got it working by creating a global variable: FREIGHT_EXISTS or type BOOLEAN.

Code initialization checks, with abap code, if the freight table is empty and assigns the appropriate value to the above variable.

In the initialization part of the Freight subform that I want to hide I just put the simple code:

if (this.FREIGHT_EXISTS.rawValue = "-" ) { this.presence = "hidden"; }

Thanks to all who answered.

Answers (0)