Repeating table in repeating table - InfoPath Dev
in

InfoPath Dev

Repeating table in repeating table

Last post 02-21-2010 11:43 PM by gerwinee. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 01-27-2010 06:04 AM

    Repeating table in repeating table

    Hello all.


    I have a repeating table inside a repeating table. Now i have the following problem. The first time the main repeating table goes through it's loop everything works fine, but the second time the main repaiting table goes through it's loop the secondary repeating table shows the values from the first loop and from the second loop.


    How can i fix this?


    Below is the code i use.


    XPathNavigator root = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group15/my:group16/my:group14", NamespaceManager);
    root = root.Clone();
    XPathNavigator root1 = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group15/my:group16", NamespaceManager);
    root1 = root1.Clone();
    XPathNavigator parentRoot = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group15/my:group16", NamespaceManager);
    for (int p = 0; p < 10; p++)
    {
       root1.SelectSingleNode(
    "my:field24", NamespaceManager).SetValue("" + p);
          for (int n = 0; n < 10; n++)
          {
             root.SelectSingleNode(
    "my:field22", NamespaceManager).SetValue(""+p);
             root.SelectSingleNode(
    "my:field23", NamespaceManager).SetValue(""+n);
             parentRoot.AppendChild(root);
          }
       deleteFirstRow(
    "/my:myFields/my:group15/my:group16/my:group14");
       XPathNavigator parentRoot1 = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group15",    NamespaceManager);
       parentRoot1.AppendChild(root1);
    }
    deleteFirstRow(
    "/my:myFields/my:group15/my:group16");
    }

    The structure of my form is as follow:

    myFields
       group15
          group16
             field24
             field25
             group14
                field22
                field23

  • 01-29-2010 12:48 AM In reply to

    Re: Repeating table in repeating table

    Kick.

  • 01-29-2010 01:47 AM In reply to

    Re: Repeating table in repeating table

     The XPathNavigator Clone() method only creates a copy of the XPathNavigator, not the node and its children, so this code:

    XPathNavigator root = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group15/my:group16/my:group14", NamespaceManager);
    root = root.Clone();

    is no different from this:

    XPathNavigator root = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group15/my:group16/my:group14", NamespaceManager);
    root = root.Clone();

    AppendChild() does create a copy of the node tree leaving the XPathNavigator as it was, so the result is that you are continually piling new children onto parentRoot every time the inner loop finishes, and then adding a copy of that to parentRoot1 at the end of each iteration of the outer root. 

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 01-29-2010 03:07 AM In reply to

    Re: Repeating table in repeating table

    Can you show me an example of how i can do what i want to do? I'm totally lost at the moment.

     The result should be:

    PN
    01
    02
    03
    0..
    11
    12
    13
    1..
    20
    21
    22

  • 02-10-2010 01:11 AM In reply to

    Re: Repeating table in repeating table

    No one who can help me??

  • 02-19-2010 06:26 AM In reply to

    Re: Repeating table in repeating table

    please, i still have this problem.

  • 02-19-2010 09:10 AM In reply to

    Re: Repeating table in repeating table

     This should do the job.  May I request that the next time you ask people to debug your code for you, that you at least use meaningful field and variable names?

    XPathNavigator topParent = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group15", NamespaceManager);
    XPathNavigator middleNode = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group15/my:group16", NamespaceManager);
    XPathNavigator innerMost = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group15/my:group16/my:group14", NamespaceManager);

    deleteFirstRow(
    "/my:myFields/my:group15/my:group16/my:group14");
    deleteFirstRow(
    "/my:myFields/my:group15/my:group16");

    for (int p = 0; p < 10; p++)
    {
         topParent.AppendChild(middleNode);
         XPathNavigator newMiddleNode = topParent.SelectSingleNode("my:group16[last()]", NamespaceManager);

         newMiddleNode.SelectSingleNode(
    "my:field24", NamespaceManager).SetValue(p.ToString());

         for (int n = 0; n < 10; n++)
         {
              newMiddleNode.AppendChild(innerMost);
              XPathNavigator newInnerNode = newMiddleNode.SelectSingleNode("my:group14[last()]", NamespaceManager);

              newInnerNode.SelectSingleNode(
    "my:field22", NamespaceManager).SetValue(p.ToString());
              newInnerNode.SelectSingleNode(
    "my:field23", NamespaceManager).SetValue(n.ToString());
         }
    }

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 02-21-2010 11:43 PM In reply to

    Re: Repeating table in repeating table

    Thank you very much.

    This was exactly what i was looking for.

    I will use meaningful field and variable names next time.

Page 1 of 1 (8 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.