1 Reply Latest reply on Oct 29, 2010 4:37 PM by The Flex Viking

    Calculate Value From XML in Table Row

    The Flex Viking Level 1

      I am binding an XML document to an XDP to generate a PDF.  The XML contains repeating data.  I have created a Table with the BodyRow set to repeat for each data item to display the repeating data.

       

      Let's assume my repeating XML looks like

       

      <Person>

        <FirstName />

        <MiddleName />

        <LastName />

        <Address />

        <City />

        <State />

        <ZipCode />

        <Telephone />

        <EmployeeID />

      </Person>

       

      So, I have the BodyRow configured to bind to $.Staff.Person[*].  And then each TextField in the BodyRow is bound to something like $.Telephone.  Easy.

       

      Now.  Let's say I want to define a new column that is a calculated value.  Say I want to generate something like LastName +  FirstName + Middle Initial + EmployeeID and neither Middle Initial or EmployeeID is bound in the table row.  I want to use FormCalc (or JavaScript) to calculate the value.  My plan was to use the calculate event on the TextField in the BodyRow.  However, I can't seem to figure out how to access the data relative to the current row.  How do I do that?

       

      I've been looking around the web and can't seem to place my finger on this and I assume this is not an uncommon need.

       

      Do I create "hidden" columns and access the data that way?

        • 1. Re: Calculate Value From XML in Table Row
          The Flex Viking Level 1

          I am not sure if this is the best way, it uses an absolute lookup of the value.  I would think I could used a relative lookup in relation to each row ....but, this works ...

           

          Use a calculate script for the TextField that needs the calculated value

           

          var index = $.parent.index
          
          $ = Concat($data.Staff.Person[index].LastName, $data.Staff.Person[index].EmployeeID)