Skip navigation
Currently Being Moderated

Possible to show/hide sections in a table?

Nov 10, 2010 9:00 AM

Hello all,

 

First post here. I've only started using LiveCycle Designer a few weeks ago, never knowing that it came with my Acrobat. I've been busy converting forms we use in our business into pdf versions that can be filled, and created some with simple scripting etc.  Anyway my most ambitious effort to date is to create a gross payroll calculator in which I would enter the total hours worked for each employee and the gross payroll is calculated. The calculations I have no issue with.

 

I am using a hidden "config" subform (thanks to kingphysh for your easy and simple example!) to store the employee names and payrates and the department they work in.

 

My main form, the one on which I am entering total time for each employee, consists of a table with a section for each department. Thus I can put all employees in a department in one section of the table and then easily do subtotals by department etc.

 

Table1

Table1.Section1

      Dept. Name | Emp. Name | Pay Rate | Total Hrs | Gross Pay|  <-- this would be one row in the section     

Table1.Section2

      Dept. Name | Emp. Name | Pay Rate | Total Hrs | Gross Pay|

Table1.Section3
      Dept. Name | Emp. Name | Pay Rate | Total Hrs | Gross Pay|

and so on. Each section also has a footer row for subtotals.

 

This form will be used at various physical locations and not every location will have all departments. Thus I want the table to show only those sections for which the corresponding departments exist based on a selection (checkbox) that is on the hidden config page.

 

Its not so much the actual scripting thats a problem, but where to put the script. Should I use a Table1 event or the checkbox event? I've tried both but neither works as desired. Or should I use an event for the individual rows in the section itself?

 

Any pointers and suggestions will be greatly appreciated!

 

 

Harry.

 
Replies
  • Currently Being Moderated
    Nov 10, 2010 9:23 AM   in reply to HarryOhm

    Hi Harry,

     

    You could have a dropdown for all of the physical locations. Then in the exit event you could have a switch statement that would change the presence property of each table:

     

    switch (this.rawValue)
    {
         case "Clonmel":
         Table1.presence = "hidden"; 
         Table2.presence = "visible";
         Table3.presence = "hidden";
         break; 
    
         case "Cork":
         Table1.presence = "visible"; 
         Table2.presence = "visible";
         Table3.presence = "hidden";
         break; 
    
    }
    

     

    Hidden will exclude the table from the layout, so that if the page is set to flowed, then the other tables will move up to take up the space.

     

    Hope that helps,

     

    Niall

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 10, 2010 10:08 AM   in reply to HarryOhm

    Hi Harry,

     

    Yes, using a series of checkboxes (one for each table) will work.

     

    Here is a sample: https://acrobat.com/#d=MnqBQrsWVc5gKwQFC9TyZA

     

    It uses radio buttons to change the presence. The same principle applies for checkboxes (by default selected = 1, not selected = 0)

     

    Therefore you can test the value of the checkbox in the click event and using an if statement make the presence of the associated table visible/hidden.

     

    Hope that helps,

     

    Niall

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 10, 2010 5:00 PM   in reply to HarryOhm

    Hi Harry,

     

    The parameter for the removeInstance is the instance number that you want to delete. This is based on a zero numbering system, so the first row is instance number '0'. In a table you would access the instance number of the row that the delete button is in by using

     

    _Row1.removeInstance(this.parent.index); 

     

    The exact script would depend on your naming convention.

     

    If you explore this example you will see that the remove instance in one table fires the click event in a button in a second table. Example here:

     

    https://acrobat.com/#d=pQcBT5qhgi8Ebx75H0r5yQ

     

     

    // '_' is shorthand for instanceManager, eg '_Row1'
    // this.parent.index tells instanceManager to remove
    // the row that the button is in. 
    
    var vCurrentRow = this.parent.index; 
    xfa.resolveNode("page2.Table2.Row1[" + vCurrentRow + "]").deleteBtn.execEvent("click");
    page1.Table1._Row1.removeInstance(vCurrentRow); 
    

     

     

    Note that the parameter for the addInstance is 1/true or 2/false, which relates to true=merging the new instance with the data model. 

     

    Hope that helps,

     

    Niall

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 15, 2010 12:27 AM   in reply to HarryOhm

    Hi Harry,

     

    With repeating elements you can un-tick the minimum count (Object > Binding palette), so that when the form is rendered there will not be an instance on the form.

     

    However because in your case the body row is the repeating element and not the section, while you can initially hide the body row, I don't think you will have much joy hiding the footer.

     

    As far as I can tell, you cannot script for the presence of the table section (visible/hidden), so having a checkbox to hide the section will probably not help.

     

    The only work around I can think of is to un-tick the min count of the body row and have the checkbox show/hide the footer row of the section.

     

    Example here: https://acrobat.com/#d=4Nj*BeqL1iG-6tfQBLoIfA

     

    If you wanted to hide the body rows as well, then you would need to loop through, see the script in the click event of the checkboxes.

     

    In relation to the headers, if you select the header row, in the Object > Pagination palette you can specify that the header row appears on subsequent pages. (this sometimes doesn't work when the table goes over many pages).

     

    While you can disallow content page breaks within content for most objects, I don't think that you can specify it for sections.

     

    Hope that helps,

     

    Niall

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points