Delete checked items in repeating table - InfoPath Dev
in

InfoPath Dev

Delete checked items in repeating table

Last post 03-17-2010 08:07 AM by ndbhatt. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 03-16-2010 11:57 PM

    Delete checked items in repeating table

    Version: Infopath 2003 
    Script: jscript
    Aim: Onclick of a button delete selected (checked) rows in a repeating table
    Error: the parameter node is not a child of this node
    Form structure:

    Myfields (root)

    group1

    group2 (repeating table)

    field1 (check box: TRUE and FALSE)
    field2 (Text)
    field3 (Text)

    I am not sure what's wrong with the code below.

    Here is the code

    function CTRL6_5::OnClick(eventObj)
    {
     var dataFieldsChildren
     var dataFieldsNode

     dataFieldsChildren=XDocument.DOM.selectNodes("/my:myFields/my:group1/my:group2/my:field1");
     dataFieldsNode=XDocument.DOM.selectSingleNode("/my:myFields/my:group1/my:group2/my:field1");

     for(i=0;i<dataFieldsChildren.length;i++)
     {  
       dataFieldsNode.removeChild(dataFieldsChildren(i));
     }
    }

     Gurus, please help.

    Thanks,

    Nik

  • 03-17-2010 01:04 AM In reply to

    Re: Delete checked items in repeating table

    In the expression A.removeChild(B), B has to be a child node of A, but in your code, dataFieldsNode and dataFieldsChildren(i) are both my:field1.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 03-17-2010 06:16 AM In reply to

    Re: Delete checked items in repeating table

    I am not sure if I got the code correct but I made the following change and it still reads the same error

    function CTRL6_5::OnClick(eventObj)
    {
     var dataFieldsChildren
     var dataFieldsNode

    //child is field1 

     dataFieldsChildren=XDocument.DOM.selectNodes("/my:myFields/my:group1/my:group2/my:field1");
    //parent is group2

     dataFieldsNode=XDocument.DOM.selectSingleNode("/my:myFields/my:group1/my:group2");

     for(i=0;i<dataFieldsChildren.length;i++)
     { 
       dataFieldsNode.removeChild(dataFieldsChildren(i));
     }
    }

    Thanks for your patience.

    Nik

  • 03-17-2010 07:55 AM In reply to

    Re: Delete checked items in repeating table

    You're still getting the error because dataFieldsChildren is a list of all the my:field1s in the form, while dataFieldsNode is the first my:group2 in the form.  There are probably my:field1 nodes that are not children of the first my:field2 node.

    Try this, changing the value in quotes if your checked value is something other than true.

     dataFieldsChildren=XDocument.DOM.selectNodes("/my:myFields/my:group1/my:group2[my:field1 = 'true']");
    //parent is group2

     dataFieldsNode=XDocument.DOM.selectSingleNode("/my:myFields/my:group1");

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 03-17-2010 08:07 AM In reply to

    Re: Delete checked items in repeating table

    Thanks a lot. It worked like a charm.
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.