Reading specific row in a Repeating Table - InfoPath Dev
in

InfoPath Dev

Reading specific row in a Repeating Table

Last post 09-01-2005 05:08 AM by jjanicik. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 08-31-2005 05:24 AM

    Reading specific row in a Repeating Table

    I am looking for syntax to read a field value from a row that the user clicks on a button or hyperlink in a repeating table.

    The intent of this is to pass the specific id field value for that row to another form that is being opened and populated.

    My current attempt to read the field value is:

    var param1=XDocument.DOM.currentNode("/dfs:myfields/dfs:datafields/d:Company/@ID").text;

    The problem is that this retrieves the id field value for the first row in the repeating table, rather than for the row that was clicked on.

    Any ideas to make this work would be sincerely appreciated.

    Jim
  • 08-31-2005 05:55 AM In reply to

    Re: Reading specific row in a Repeating Table

    You can do the following. It is in VBScript, in JScript you would call parseInt(...) instead of CInt(...)

    Function GetCurrenntFooIndex
    GetCurrenntFooIndex = CInt(XDocument.GetNamedNodeProperty(XDocument.DOM.selectSingleNode("//my:Foo"), "CTRL656", -1))
    End Function

    You will need to extract all of your files from the XSN and go into the view. Then search for xdRepeatingTable and find the xd:CtrlId.

    Note that -1 will be returned if there is any error. Suggest putting it into a constant.

    Finally I have only been able to get this code to work if I go to the Repeating Table property window, click on the Master/Detail tab, and select the Set as Master option, even though the table is not a master/child table. Can anyone explain that?
    Jason
    http://www.k2distillery.com/
  • 08-31-2005 06:00 AM In reply to

    Re: Reading specific row in a Repeating Table

    Hi,

    try (sorry it's in c#):

    string param = e.Source.selectSingleNode("/dfs:myfields/dfs:datafields/d:Company/@ID").text

    ++

    Thierry

    Every moment hesitated is a moment gone for life!!! Think about it
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
  • 08-31-2005 09:55 AM In reply to

    Re: Reading specific row in a Repeating Table

    Thanks for the suggestions.

    One question from a newbie:

    How do I declare the object "e" in the following code that you suggested:

    e.Source.selectSingleNode("/dfs:myfields/dfs:datafields/d:Company/@ID").text

    I tried using eventobj instead of e and that did not work either.

    Thanks for your help.
  • 08-31-2005 12:04 PM In reply to

    Re: Reading specific row in a Repeating Table

    That "e" object reference would only work if the code was placed inside of an event handler. That may or may not be what you need. The author did not specify which event in the Repeating Table would be used.

    If you have a button on your form that will open another form I think that the code I referenced above may be what you need. You could write something like:

    Dim iCurrentIndex = GetCurrenntFooIndex()
    If iCurrentIndex <> -1 Then
    XDocument.DOM.selectNode("//my:Foo")(iCurrentIndex)
    End If
    Jason
    http://www.k2distillery.com/
  • 09-01-2005 05:08 AM In reply to

    Re: Reading specific row in a Repeating Table

    Thanks to all who helped. I finally got it working. I used this

    e.Source.selectSingleNode("@ID").text

    rather than this

    e.Source.selectSingleNode("/dfs:myfields/dfs:datafields/d:Company/@ID").text

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