loop/specific cell in repeating table - InfoPath Dev
in

InfoPath Dev

loop/specific cell in repeating table

Last post 05-07-2007 07:38 AM by rubinoae. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 05-06-2007 02:29 PM

    loop/specific cell in repeating table

    for(var i = 0; i < XDocument.DOM.selectNodes("my:myFields/my:group1/my:group2").length; i++)

    {

    XDocument.UI.Alert(XDocument.DOM.selectSingleNode("my:myFields/my:group1/my:group2[i]/my:pickupReady").text);

    }

    I can't seem to get this to work.  group2 is a repeating table with a cell containing a checkbox, pickupReady.  I want to cycle through the rows and evaluate whether or not the checkbox is clear. the following works:

    XDocument.UI.Alert(XDocument.DOM.selectSingleNode("my:myFields/my:group1/my:group2[1]/my:pickupReady").text);

    I can enter any number as long as there is a corresponding row but i don;t want to manually enter the row number, i want it done programmatically using the variable "i".

    When I use the variable "i" as I did at the very top infopath errors out and says an object is required.  Why can't I use the variable?  I have also tried the following:

    XDocument.UI.Alert(XDocument.DOM.selectSingleNode("my:myFields/my:group1/my:group2["+ i +"]/my:pickupReady").text);

    again it isn;t working... anyone have a suggestion?

  • 05-07-2007 05:26 AM In reply to

    Re: loop/specific cell in repeating table

    I am now not 100% but is there a position 0 for repeating tables ? So my best guess would be to try for(var i = 1; i <= XDocument.DOM.selectNodes("my:myFields/my:group1/my:group2").length;i++) and you cannot use [i] you have to use the second syntax you posted [" + i + "].

    Does it help ?

    Listen to Motörhead cos they play Rock'n Roll :)
  • 05-07-2007 06:10 AM In reply to

    Re: loop/specific cell in repeating table

    Nukkumati is correct. There is no position 0 in XML. Weird, huh?

    To avoid these problems, use the preffered method of looping:

    var list = XDocument.DOM.selectNodes( "_xpath_to_repeating_structure_" );
    var node;
    while( ( node = list.nextNode()) != null )
    {
        XDocument.UI.Alert( node.text );
    }


    If you're using C#, you can use the foreach, and it's even a little cleaner.
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 05-07-2007 07:38 AM In reply to

    Re: loop/specific cell in repeating table

    ah, man. there is always an easy answer.  I shoould have asked the question HOURS ago.  thanks guys, the solution works great.  Now in order to evaluate the specific field in the specific row i changed the code block within the while loop to this:

    XDocument.UI.Alert(node.selectSingleNode("my:pickupReady").text);

     and it all works great.

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