Expand my Community achievements bar.

Table column width - runtime adjustment

Avatar

Level 2

Hi,

I have a form with a dual purpose. In one instance it is a notification of expected changes to amounts, and in the other it is the findings of the audit. They appear the same with slight wording changes - all the wording is in the data and that allows us the leverage to have one template.

However, there is a table on this form and in the one instance I want to show a certain column and in the other I dont want the column. So, can I make this adjustment at runtime when the data is merged?

Thanks

6 Replies

Avatar

Former Community Member

Unfortunately you cannot change the binding expressions dynamically but you can determine which form you have and set the presence of the fields you do not want to show to hidden.

Paul

Avatar

Level 2

Ok, I was hoping that was my last option. So I wont be able to have one form with 3 columns that stretch the width of the page and another with a table and 4 columns that stretch the the width of the page?

What is the best option here, using two tables and showing the correct one accordingly?

The scenario is that there are 4 different companies involved in the running of the whole project and whatever changes I make to the XSD impacts everyone!

Avatar

Former Community Member

Depending how good you are at scripting you coudl change the width of the fields in the columns dynamically based on which structure you want to use. You woudl still have to use the hidden technique to get rid of the other column though.

Or as you suggest you coudl use two different tables and simply make the one that is not used hidden.

Paul

Avatar

Level 2

Cool, I wont say I am a slouch at scripting but where would you achieve this? I have set the width of the column to be 0 depending on data being pulled in but I get no change?

Avatar

Former Community Member

You woudl have to change the width of the column as well as the width of the objects in that column. Use the layout ready event and use this.w to set the width and this.h to set the height.

Paul

Avatar

Level 4

Hi,

Its not really easy to code, but I did something  similar a few years ago.

Basically there's a bunch of fields that adjust their width according to the data used in the PDF generation. When a field is empty it will be removed. If there’s a break the last field of the line will stretch till it occupies all the area of the parent subform, kind of justifying a text.

I would attach the form and test data, but it appears this feature has been disabled.

try{
     var oldField;
     var newField;
     var first=true;
     var maxLine=measure(this.w);
     var line=0;
     for (var j=0; j<this.nodes.length; j++){
          if (this.nodes.item(j).className=="subform"){
               newField=this.nodes.item(j);
               
               if (newField.nodes.item(0).rawValue==null || newField.nodes.item(0).rawValue==""){
                    newField.nodes.item(0).presence="hidden";
                    newField.presence="hidden";
                    newField.w="0mm";
                    newField.nodes.item(0).w="0mm";
               }else{
                    line+=Number(measure(newField.nodes.item(0).w));
                    if (!first && line > maxLine){
                         line-=Number(measure(newField.nodes.item(0).w));
                         stretch(oldField, Number(maxLine-line));
                         line=Number(measure(newField.nodes.item(0).w));
                    }else{
                         first = false;
                    }     
               oldField=newField;     
               }
          }
     }
}catch(e){app.alert(e);}


function measure(num){
     return num.substring(0,numero.length-2);
}


function stretch(field, lim){
     var nos = field.nodes;
     var lim=Number(Number(measure(field.nodes.item(0).w))+lim)+"mm";
     field.nodes.item(0).w=lim;
}

Hope this helps.