Repeating Tables - InfoPath Dev
in

InfoPath Dev

Repeating Tables

Last post 05-09-2006 08:43 AM by Matt Faus. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 05-08-2006 06:05 AM

    Repeating Tables

    Hi all,

    I have a form with a repeating table. When the user clicks a button another form gets merged into the current one. sometimes it happens that there are two identical tables within the form. can i somehow check if two of the repeating tables are the same and delete one of them ?

    Some ideas, thx guys
    Listen to Motörhead cos they play Rock'n Roll :)
  • 05-08-2006 07:26 AM In reply to

    This should be pretty easy to do in code. The hard part will be determining whether or not two tables are the same. If they are exactly the same, you might be able to compare objects, but I have not tried this. Otherwise I think you will have to walk the DOM and determine whether or not two nodes are precisely the same by a series of string comparisons (is field1 in table1 equal to field1 in table2?). If you you wanted to make a generic function that does this, it will have to be recursive, but otherwise you could just do it iteratively.

    I hope this has made sense, please post back if you are unclear or have any other questions!
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 05-09-2006 12:29 AM In reply to

    Hi Matt,

    thx for your porposals. I realzied that i don't have to check if they are the same i can just delete the first, second, third... (following an algorithm) node of the table but somehow it does not work. Can you tell me how to delete for example the first node (the whole row) of a repeating table ( i am using c#)

    Thx a lot
    Listen to Motörhead cos they play Rock'n Roll :)
  • 05-09-2006 12:41 AM In reply to

    Hi,
    You can use this XPath to get the first row of the repeating table
    "/Root/ReapeatingNode[position() = 1)"

    Where "ReapeatingNode" is the reapeating node in your XML.
    Once you get the first node just use removeChild on parent node/
  • 05-09-2006 01:02 AM In reply to

    Hi Agni

    first thank you for your fast reply.
    But I still get an Object Reference not set....
    when using this code:

    IXMLDOMNode node = thisXDocument.DOM.selectSingleNode("my:myFields/my:Main/my:group1/group2[position() = 1]");
    node.parentNode.removeChild(node);


    or should i use

    IXMLDOMNode node1 = thisXDocument.DOM.selectSingleNode("my:myFields/my:Main/my:group1");
    IXMLDOMNode node = thisXDocument.DOM.selectSingleNode("my:myFields/my:Main/my:group1/group2[position() = 1]");
    node1.removeChild(node);

    what returns an incorrect parameter error

    Is there something wrong with my brackets, I have no idea anymore ?

    OKAY i found out what was wrong. I used

    IXMLDOMNode node = thisXDocument.DOM.selectSingleNode("my:myFields/my:Main/my:group1/group2[position() = 1]");

    instead of using:

    IXMLDOMNode node = thisXDocument.DOM.selectSingleNode("my:myFields/my:Main/my:group1/my:group2[position() = 1]");

    Always these damn little things, I really could explode.
    Thx for help anyway
    Listen to Motörhead cos they play Rock'n Roll :)
  • 05-09-2006 06:22 AM In reply to

    Good to know that you were able to figure out the issue by yourself. Please let post here if have any more issues.
  • 05-09-2006 08:43 AM In reply to

    I think the ratio of namespaces being annoying to being helpful is around 1000:1.
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.