Deleting a full row in a repeating table - InfoPath Dev
in

InfoPath Dev

Deleting a full row in a repeating table

Last post 10-04-2011 11:03 AM by Padraic. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 09-29-2011 06:29 AM

    Deleting a full row in a repeating table

    Hi, I would be grateful if someone could help me with some help on programmatically deleting a full row in a repeating table in InfoPath 2010. I have 3 fields in a repeating table as follows: legislationselected (Checkbox) legislationcategory (textbox) legislationref (textbox) I would like to be able to loop through the repeating table rows and determine if the legislationselected checkbox has been selected. If it has then I want to be able to delete that entire row and only that row. I have tried coding it but I only had success with unchecking the legislation checkbox, which is not what I require. The code snippet for Delete button on the InfoPath 2010 form is as follows: public void btnDelete_Clicked(object sender, ClickedEventArgs e) { const string f1 = "/my:Referral/my:LegislationDetails/my:LegislationRecord/my:legislationselected"; XPathNavigator root = MainDataSource.CreateNavigator(); XPathNavigator selectedLegislation = MainDataSource.CreateNavigator().SelectSingleNode("//my:LegislationDetails", NamespaceManager); XPathNodeIterator legislationItems = selectedLegislation.Select(f1, NamespaceManager); foreach (XPathNavigator legislationItem in legislationItems) { string msg = legislationItem.Value; if (msg == "true") { legislationItem.DeleteSelf(); } } } I would be extremely grateful for any help you can provide on this matter. Thanks, Padraic
  • 10-02-2011 12:27 PM In reply to

    Re: Deleting a full row in a repeating table

     Really would appreciate some help with this issue!

     Thanks,

  • 10-02-2011 03:06 PM In reply to

    Re: Deleting a full row in a repeating table

    qRules has a function called Delete and it's documented in the User Guide. Free trial and it has 60+ other functions you can use.
    Patrick Halstead
    Project Manager at Qdabra
  • 10-04-2011 01:39 AM In reply to

    Re: Deleting a full row in a repeating table

    Thanks for the information Patrick.

     However, I would prefer to solve the problem without having to use third-party tools.

    So, if anyone has any suggestions, I would be extremely grateful.

  • 10-04-2011 09:47 AM In reply to

    Re: Deleting a full row in a repeating table

    No problem. There should be examples in this forum ove the last 7 years that show how to delete rows. You'll need to write some code.
    Patrick Halstead
    Project Manager at Qdabra
  • 10-04-2011 11:03 AM In reply to

    Re: Deleting a full row in a repeating table

    Just to follow up on this and close this issue out.

    I solved the problem thanks to an MSDN article I found that was written by David Gerhardt. I had to amend his code sample slightly to get it to work with my scenario.

    The code snippet that I finally used was as follows:

    public void btnDelete_Clicked(object sender, ClickedEventArgs e)

    {      

    XPathNavigator selectedLegislation = MainDataSource.CreateNavigator().SelectSingleNode("//my:LegislationDetails", NamespaceManager);        

    XPathNodeIterator legislationItems = selectedLegislation.Select("./my:LegislationRecord", NamespaceManager);          

    if (legislationItems.Count > 0)

    {              

         for (int i = legislationItems.Count; i > 0; i--)

    {                  

    XPathNavigator legislationItem = selectedLegislation.CreateNavigator().SelectSingleNode("my:LegislationRecord[position() = " + i + "]", NamespaceManager);                 

    if (legislationItem.SelectSingleNode("my:legislationselected", NamespaceManager).Value == "true")

    {

    legislationItem.DeleteSelf();

    }

    }

    }

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