Comparing rows of a repeating section or table - InfoPath Dev
in

InfoPath Dev

Comparing rows of a repeating section or table

Last post 01-03-2008 02:37 PM by Swanee. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 10-27-2005 10:30 PM

    • qwer
    • Top 500 Contributor
    • Joined on 10-04-2005
    • Posts 49

    Comparing rows of a repeating section or table

    Hi,

    My form has a repeating section that allows users to insert rows. Each row requires a FromDate and a ToDate. What is the easiest way to evalutes the values from one row to another row? eg, I want to validate the rows so that no FromDate equals to another FromDate on another row. Thanks!
  • 10-28-2005 06:10 AM In reply to

    Re: Comparing rows of a repeating section or table

    Hi,

    Did you try to use code to do this?
    You can refer to a specific field on the nth row of your table using code such as:
    IXMLDOMNode oNode = thisXDocument.DOM.selectSingleNode("/my:myFields/my:group1/my:group2[n]/my:field1");

    Hope that it helps.


    Regards,

    Franck Dauché
  • 10-30-2005 03:34 PM In reply to

    • qwer
    • Top 500 Contributor
    • Joined on 10-04-2005
    • Posts 49

    Re: Comparing rows of a repeating section or table

    Thanks franck. I was hoping for an easier way out. But I am exploring your suggestion. Can you also tell me the syntax on how to check whether I have reached the last row of the repeating table as I am implementing a FOR or do-until loop? Thanks again!
  • 10-30-2005 04:29 PM In reply to

    Re: Comparing rows of a repeating section or table

    Hi,

    To loop through your nodes, use something like:

    IXMLDOMNodeList oNodeList = thisXDocument.DOM.selectNodes("my:myFields/my:group1/my:group2");
    if (oNodeList.length>0)
    {
    foreach (IXMLDOMNode oN in oNodeList)
    {
    if( oN.nodeType == DOMNodeType.NODE_ELEMENT )
    {
    IXMLDOMNode oField = oN.selectSingleNode("my:field1");
    thisXDocument.UI.Alert(oField.text);
    }
    }
    }

    Regards,

    Franck Dauché
  • 10-31-2005 07:09 AM In reply to

    Re: Comparing rows of a repeating section or table

    Why do you have to put in "if (oNodeList.length>0)" - shouldn't the foreach only run if that condition is true? It seems like you're stating something explicitly that is implied in the foreach statement... I'm confused.

    ---------------
    Matt Faus
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 04-17-2006 07:09 AM In reply to

    Re: Comparing rows of a repeating section or table

    I have a similar problem, but when I tried to use the example code on a new form I got the following message:

    quote:
    InfoPath cannot open the selected form because of an error in the form's code.
    The following error occurred:

    Expected ';'
    File:script.js
    Line:26
    IXMLDOMNodeList oNodeList = thisXDocument.DOM.selectNodes("my:myFields/my:group1/my:group2");


    There's not actually any missing ;s as far as I can tell. Any idea what might cause this? Where did you put your code? Behind a button?

    Thanks.
  • 04-17-2006 09:26 AM In reply to

    Re: Comparing rows of a repeating section or table

    Hi Marien,

    The code example given is in C#.NET, which is managed code. You are using JScript. The equivalent in JScript would be as follows:


    var oNodeList = XDocument.DOM.selectNodes("my:myFields/my:group1/my:group2");

    var oNode;

    while( (oNode = oNodeList.nextNode()) != null )
    {
    if( oNode.nodeType == 1 )
    {
    var oField = oN.selectSingleNode("my:field1");
    XDocument.UI.Alert(oField.text);
    }
    }

    See this link for further info on nodeType:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/039aa2c8-2414-43e8-82cf-3e056eebb2f4.asp

    Hope this helps!
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 01-03-2008 02:37 PM In reply to

    • Swanee
    • Not Ranked
    • Joined on 11-26-2007
    • Posts 2

    Re: Comparing rows of a repeating section or table

    Worked like a charm. Thanks!

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