This is a migrated thread and some comments may be shown as answers.

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

3 Answers 78 Views
RichTextEditor
This is a migrated thread and some comments may be shown as answers.
Mihajlo
Top achievements
Rank 1
Iron
Mihajlo asked on 31 Oct 2018, 04:51 PM

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?

3 Answers, 1 is accepted

Sort by
0
Boby
Telerik team
answered on 05 Nov 2018, 12:37 PM
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.
0
Mihajlo
Top achievements
Rank 1
Iron
answered on 05 Nov 2018, 03:41 PM
Actual code also makes use of ProtectDocument and InsertPermissionRange methods. I submitted a ticket with some code that exhibits the problem.
0
Accepted
Boby
Telerik team
answered on 06 Nov 2018, 08:59 AM
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.
Tags
RichTextEditor
Asked by
Mihajlo
Top achievements
Rank 1
Iron
Answers by
Boby
Telerik team
Mihajlo
Top achievements
Rank 1
Iron
Share this question
or