How to cancel a changed item - InfoPath Dev
in

InfoPath Dev

How to cancel a changed item

Last post 11-03-2008 05:05 AM by Francois Larose. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 10-29-2008 07:38 PM

    How to cancel a changed item

    Hi,

    I'm able to use Changed and Validating event and I know what user try to do by code.  I like to know it I can "undo" his change ?!  (or not apply, sound better)  My post is in my form context; C#, browser enabled on Form server.

     Thank you,

     Frank

  • 10-29-2008 09:21 PM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: How to cancel a changed item

    Hello Welcome to the Forums,

    Undo operation also executes Changed and Validating events. Do you want to stop this operation then you have to include one line code in your solution,

    if(e.IsUndoRedo)

    {

    return;

    }

    This above condition will works for Validating and Changing events but not works for Changed event.

  • 10-30-2008 09:08 AM In reply to

    Re: How to cancel a changed item

    Hi,

    Okay, maybe I have to expose with more detail my goal.

    I'm in a repeating table contexte.  Some entry ares read-only and some other can be deleted.  When a user try to delete one row in my repeating table, I have to catch Delete event (I can) find my Flag to know if it's a read only row or not and then, permit to delete or block this XML change...

    At the same time, can we disable Event Handler to control "cascading fire Event" ... I try to make carefull at this but it very hard to do not fire more than one Event at the time.

     

    Thank you,

    Frank

  • 10-30-2008 09:38 AM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: How to cancel a changed item

    Hello,

    The easiest way to prevent this is to set a global flag (variable) which states that your OAC event handler is making DOM changes. Then at the top of your handler, if that flag is set to true, return out and don't process that event further.

    Then just set the flag to false when done, so that you handler works again later. Here is the code, 

    public void SomeField_OnAfterChange(...)
    {
        if(e.UndoRedo || e.Operation != "Insert" || fIsUpdatingFields == true)
            return;

        fIsUpdatingFields = true;

        // Modify DOM here.

        fIsUpdatingFields = false;
    }

    More details on this go through this link,

    http://www.infopathdev.com/blogs/greg/archive/2004/07/07/Avoid-an-Endless-Loop-During-Event-Bubbling.aspx

  • 11-03-2008 05:05 AM In reply to

    Re: How to cancel a changed item

    Hi,

     Thank you.  It work fine to control cascading Event.

     

    But, for my first question, any way to do it?  During a Validating event or any thing like this, check modification and void any change if it's not permit ?  I know, I can use a Rule on each single control in one row but it can be pain in the ass to go in this way.  My row have more than 10 controls and I have to add a minimum of two Rule on each one...

     Good day!

     

     

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