Delete a row from a repeating table - InfoPath Dev
in

InfoPath Dev

Delete a row from a repeating table

Last post 12-29-2009 09:53 AM by Jimmy. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 12-16-2009 07:45 AM

    Delete a row from a repeating table

    I would like to have a button that is outside a repeating table that will delete a specific row if a checkbox is checked. 

    I know how to do this if the button is in the same row of the repeating table, but i want to delete it if the button is not within the repeating table.  A button outside outside the repeating table.

    Any ideas?

    Thanks!

  • 12-16-2009 09:31 PM In reply to

    Re: Delete a row from a repeating table

    i hope you are using code for this one.

    through code loop through your repeating section and check for the value of checkbox, the node for which checkbox is selected delete that. you will need to make sure that the previous node now points to the node that is after the deleted node.

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 12-17-2009 07:09 AM In reply to

    Re: Delete a row from a repeating table

    I am.  This is what i have thus far. The problem is, after it deletes the current node the loop stops; it doesn't continue on to the next node (probably because I deleted a row and now it's confused or something).  How do you "make sure that the previous node now points to the node that is after the deleted node"?  Here's my code.... please help!

     

     

    XPathNodeIterator table = MainDataSource.CreateNavigator().Select("/dfs:myFields/dfs:dataFields/d:SUBMIT_TABLE", NamespaceManager);

     

    while (table.MoveNext())

    {

    string SubmitID = table.Current.SelectSingleNode("@SubmitID", NamespaceManager).Value;

    string chkbox = table.Current.SelectSingleNode("@CHKBOX_SELECTION", NamespaceManager).Value;

    if (chkbox == "1")

    {

    XPathNavigator DelRow = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:SUBMIT_TABLE[" + SubmitID + "]", NamespaceManager);

    DelRow.DeleteSelf();

     

    }

    else

    {

     

    }

    }

  • 12-17-2009 07:48 AM In reply to

    Re: Delete a row from a repeating table

     You need to place the rows you want to remove in an array and remove them after the loop is finished.  Otherwise, the loop will stop prematurely.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-29-2009 07:56 AM In reply to

    Re: Delete a row from a repeating table

    can you show me an example?

    I am a little unsure on how to do that.

  • 12-29-2009 09:53 AM In reply to

    Re: Delete a row from a repeating table

     Adding items to an array and iterating through them is a fairly elementary matter and if your coding expertise isn't up to that level, I would caution against trying to use code in your form as it may become a maintenance liability later on.

     Here at Qdabra we try to discourage using custom code in forms (including in our own internal forms) because of the troubleshooting and maintenance requirements it brings.  That's why we developed qRules.

    With qRules, you can accomplish this task with a single, simple command:

     Delete /xpath=/dfs:myFields/dfs:dataFields/d:SUBMIT_TABLE[@CHKBOX_SELECTION = 1]

     I would suggest downloading the trial version and giving it a spin.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.