Prevent deleting of first row of repeating table - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Prevent deleting of first row of repeating table

Last post 06-19-2009 10:13 PM by swathip. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 06-19-2009 11:13 AM

    Prevent deleting of first row of repeating table

    I'm hoping there's an easy answer to this.  Is there anyway to prevent users from deleting the first row of the repeating table?  We want them to always have at least one row filled in but be able to add/delete additional rows if needed.

    I can't make the first row required because they are allowed to save as "draft" so making it required defeats the purpose of the draft. 

    Any ideas?  Hopefully it wouldn't happen often but I worry someone would accidently delete all the rows of the table and then submit a Purchase Req with no items. I did remove the option for "remove all items" but can't get rid of "remove one item" b/c then they won't be able to remove any of them.

    Thanks for any ideas!

    Filed under:
  • 06-19-2009 10:13 PM In reply to

    Re: Prevent deleting of first row of repeating table

    Hi,

    We can prevent the user to delete the row when there is only one row using the on before change event. Once follow the below code (This is in C#).

    [InfoPathEventHandler(MatchPath = " /my:myFields/my:group1/my:group2", EventType = InfoPathEventType.OnBeforeChange)]

    public void group2_OnBeforeChange(DataDOMEvent e)

    {

    if (e.Operation != "Insert" && thisXDocument.Dom.SelectNodes("/my:myFields/my:group1/my:group2").length == 0)

    {

    e.ReturnMessage = "Cannot delete the row.";

    e.ReturnStatus = false;

    }

    }

     

    Swathip
    www.ggktech.com
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.