Expand my Community achievements bar.

SOLVED

Auto fit Subform....

Avatar

Former Community Member

ImportantImage.GIF

Hi,

Please refer the above image..

Here I want to know if there is a solution for auto adjusting the width of subforms.

In above image--I have 3 subfroms wrapped in SubformA..

If the name field is blank or null then the Date and Country field should be adjusted in such a way that the Width of the Main Subform remains same and the Date and country field occupy the whole subformA.

Please suggest some solution.

Thanks in Advance.

----Amol


1 Accepted Solution

Avatar

Correct answer by
Level 8

Hi Amol,

Now I'm assuming that the fields are adjusted AFTER data has been brought in (since you can't enter data into an empty field if that field is hidden!).

If that's the case copy this JavaScript code into the docReady event of your SubformA:

HideExpand(xfa.layout.w(this,"in"),Subform1.Name,Subform2.Date,Subform3.Country); //the first parameter is the width of SubformA, then rest you can add as many as you want

function HideExpand(subFormWidth/*, list of Field objects*/){
var showObjects = new Array();
for (var a=1;a<arguments.length;a++){
  if (arguments[a].isNull){
   arguments[a].presence="hidden";
  }
  else{
   arguments[a].presence="visible";
   showObjects.push(arguments[a]);
  }
}
for (a=0;a<showObjects.length;a++){
  showObjects[a].w=(subFormWidth/showObjects.length)+"in";
}
}

Kyle

View solution in original post

2 Replies

Avatar

Correct answer by
Level 8

Hi Amol,

Now I'm assuming that the fields are adjusted AFTER data has been brought in (since you can't enter data into an empty field if that field is hidden!).

If that's the case copy this JavaScript code into the docReady event of your SubformA:

HideExpand(xfa.layout.w(this,"in"),Subform1.Name,Subform2.Date,Subform3.Country); //the first parameter is the width of SubformA, then rest you can add as many as you want

function HideExpand(subFormWidth/*, list of Field objects*/){
var showObjects = new Array();
for (var a=1;a<arguments.length;a++){
  if (arguments[a].isNull){
   arguments[a].presence="hidden";
  }
  else{
   arguments[a].presence="visible";
   showObjects.push(arguments[a]);
  }
}
for (a=0;a<showObjects.length;a++){
  showObjects[a].w=(subFormWidth/showObjects.length)+"in";
}
}

Kyle

Avatar

Former Community Member

Hi Kyle,

          Thank you for the reply...

This really worked..I was unaware about the push to be used on arrays in Adobe...

Thank You once again..

--Amol