Advanced Expanding Tables and Script Objects in Adobe LiveCycle ®

This tutorial demonstrates how Scripting Objects can be used to make more robust and better organized forms. Also, I demonstrate how to use check boxes to manipulate data rows in an expanding table.

Here is the code used in the Script Object and Check Boxes:

SO:
function addToTable(component, check_caption, check_uncheck)
{
 var rowNum = component._Row1.count;
 if (check_uncheck == 1)  //check if click was on or off
 {        //if on then add the row to the table
   if (rowNum == 0)
     {
      component._Row1.addInstance();
      component.Row1.Cell1.rawValue = check_caption;
     }
   else if (rowNum == 1)   //if 1 and no value assign value
     {
        if (component.Row1.Cell1.rawValue == null)  //check for available row
          {
           component.Row1.Cell1.rawValue = check_caption;
          }
        else      //if 1 and value add row and assign value
          {
            component.Row1.instanceManager.addInstance();
            component.resolveNode(“Row1[1]”).Cell1.rawValue = check_caption;

          }
     }
   else if (rowNum > 1)
     {
       component.Row1.instanceManager.addInstance(); //count rows – if greater than 1 add row and assign value
       component.resolveNode(“Row1[” + rowNum +”]”).Cell1.rawValue = check_caption;
     }
 }
 else         //if off then delete the row from the table
 {
  var rows = component.resolveNodes(“Row1[*]”);
  var row = component;
  for (var i=0; i<rows.length; i++) //find the correct row
  {
    var currentRow = rows.item(i);
    if (currentRow.Cell1.rawValue == check_caption)
    {
     component._Row1.removeInstance(i);
    }
  }
 }
}


Check Boxes:
SO.addToTable(this.parent.Table1, this.resolveNode(“caption.value.#text”).value, this.rawValue);

Leave a Reply

HTML Snippets Powered By : XYZScripts.com