Track if document is modified by user, but not from code

4 posts, 1 answers
  1. Mihajlo
    Mihajlo avatar
    38 posts
    Member since:
    Aug 2018

    Posted 31 Oct 2018 Link to this post

    I am tracking if document is modified by user so that I can append the text "(modified)" to the form's title, and also to prompt the user to save the modified document. My code also changes the document, but this is not a modification that the user should be concerned with. TextChanged event is alas raised in both cases. So I introduced a flag that means "ignore TextChanged event once". If in event handler the flag is set then just reset it. Otherwise update the form's title.

    And now I've added default footer with code, in the same place where all other code changes to the document are made. This causes two events to fire, instead of just one. And now my document is marked as modified from the start. I could change the meaning of the introduced flag to mean "ignore TextChanged event twice", but that now just feels like a hack. Is there a "proper" way to track user's changes and not track changes from the code?

  2. Boby
    Admin
    Boby avatar
    718 posts

    Posted 05 Nov 2018 Link to this post

    Hello Mihajlo,

    I've tried the following setup:
    this.radRichTextEditor1.TextChanged += (s, args) => MessageBox.Show(changed);
    this.radRichTextEditor1.UpdateFooter(this.radRichTextEditor1.Document.Sections.First, HeaderFooterType.Default, new Footer() { Body = new TxtFormatProvider().Import("test") });

    and the event was raised only once.

    Could you send us sample code demonstrating how are you setting the footer, do you use RadRichTextEditor.UpdateFooter, RadDocumentEditor.ChangeSectionFooter, or direct model change?

    Regards,
    Boby
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Mihajlo
    Mihajlo avatar
    38 posts
    Member since:
    Aug 2018

    Posted 05 Nov 2018 in reply to Boby Link to this post

    Actual code also makes use of ProtectDocument and InsertPermissionRange methods. I submitted a ticket with some code that exhibits the problem.
  4. Answer
    Boby
    Admin
    Boby avatar
    718 posts

    Posted 06 Nov 2018 Link to this post

    Thanks Mihajlo, 

    We are working together with Hristo on the internal ticket you opened.

    Regards,
    Boby
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top