Add a New Blank Row to a Repeating Table More opti - InfoPath Dev
in

InfoPath Dev

Add a New Blank Row to a Repeating Table More opti

Last post 03-21-2007 08:17 PM by YoungSC. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 02-28-2007 10:33 PM

    • YoungSC
    • Not Ranked
    • Joined on 02-28-2007
    • Australia
    • Posts 13

    Add a New Blank Row to a Repeating Table More opti

    I want to mimic the functionality of the "Insert Item" function in
    InfoPath for a repeating table using code triggered by a button
    press. The reason is, I am designing forms for users which includes
    people who don't have the best computer skills and may not notice or
    know how to use this InfoPath function.

    I have found the following code:


    Dim row As XPathNavigator
    row = MainDataSource.CreateNavigator.SelectSingleNode("/
    my:myFields/my:group3/my:group4", NamespaceManager)
    row.Clone()


    Dim parent As XPathNavigator
    parent = MainDataSource.CreateNavigator.SelectSingleNode("/
    my:myFields/my:group3", NamespaceManager)
    parent.AppendChild(row)


    This works, but also adds any text entered in the child fields of
    cloned node. I want to add a new row without any text. I have tried
    individually changing the text values of the children nodes using
    row.selectSingleNode("XPath").text, but text isn't compatible with the
    XPathNavigator object.


    I have very limited programming experience so I am not familiar with a
    correct object or solution to what I am trying to achieve and would
    appreciate some direction.


  • 02-28-2007 11:15 PM In reply to

    Re: Add a New Blank Row to a Repeating Table More opti

    Hi,

    please refer to the follwing thread http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=3970


    Let me know if it helped.
    Listen to Motörhead cos they play Rock'n Roll :)
  • 03-01-2007 03:30 PM In reply to

    • YoungSC
    • Not Ranked
    • Joined on 02-28-2007
    • Australia
    • Posts 13

    Re: Add a New Blank Row to a Repeating Table More opti

    Thanks for the reply Nukkumatti,

    I'm using InfoPath 2007 and it didn't like things like thisXDocument and IXMLDOMDocument. I tried C# 2003 compatible and it didn't like async, loadXML & documentElement.

    If possible I was hoping for code in VB as I don't know the other languages.

    Thanks,

    Simon
  • 03-15-2007 04:09 PM In reply to

    • YoungSC
    • Not Ranked
    • Joined on 02-28-2007
    • Australia
    • Posts 13

    Re: Add a New Blank Row to a Repeating Table More opti

    Bueller.................Bueller.................Bueller................. :)
  • 03-21-2007 08:17 PM In reply to

    • YoungSC
    • Not Ranked
    • Joined on 02-28-2007
    • Australia
    • Posts 13

    Re: Add a New Blank Row to a Repeating Table More opti

    I sat down with a colleague and we nutted it out. For those who may need help for the solution in VB, here it is:

    Dim newxmlstring As String
    Dim newrow As XmlDocument = New XmlDocument
    Dim Parent As XPathNavigator

    'Build XML needed for empty node
    newxmlstring = "<my:group4><my:field1></my:field1><my:field2></my:field2><my:field3></my:field3></my:group4>"
    'Create a new empty node
    newrow.AppendChild(newrow.CreateElement("group4"))
    'Define Parent
    Parent = MainDataSource.CreateNavigator.SelectSingleNode("/my:myFields/my:group3", NamespaceManager)
    'Add new node to parent as XML
    Parent.AppendChild(newxmlstring)
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.