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

AppendDocument not giving expected results?

3 Answers 65 Views
RichTextEditor
This is a migrated thread and some comments may be shown as answers.
Larry
Top achievements
Rank 1
Veteran
Larry asked on 28 Jul 2020, 02:47 AM

I have code like the following:

        public RadDocument SetPracticeNotesRtf(string practiceNotes)
        {
            return !string.IsNullOrEmpty(practiceNotes) ? new RtfFormatProvider().Import(practiceNotes) : null;
        }

In the code block (a loop) I am working with:

                                    var docMerger = new RadDocumentMerger(SetPracticeNotesRtf(firstNoteRtf));
                                    docMerger.AppendDocument(SetPracticeNotesRtf(nextNoteRtf));
All code is working exactly as intended (the Rtf strings are well formed, etc.)--except that I don't get a merger.  The firstNoteRtf does not change (other than the attempted merger) while the nextNoteRtf changes with each new record.

The intent is to consolidate log entries (all entries for a given day merged into one). However, no matter how I juggle the first/next etc. I always end up with either the first note or the last note - only.

What am I missing?

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 28 Jul 2020, 08:27 AM

Hello Larry,

I was not able to reproduce the observed behavior on my end. For convenience, I prepared a small sample, based on the information that you provided so far and attached it to this thread. Could you please check it and let me know how it differs from your real setup? 

Thank you in advance for your patience and cooperation. 

Regards,
Dimitar
Progress Telerik

0
Larry
Top achievements
Rank 1
Veteran
answered on 28 Jul 2020, 11:03 PM

The key was that this code did not work:

                        practiceLog.NotesRtf = GetPracticeNotesRtf(SetPracticeNotesRtf(nextNoteRtf));

But this did:

                        if (docMerger != null)
                        {
                            var rt = new RadRichTextEditor {Document = docMerger.Document};
                            practiceLog.NotesRtf = GetPracticeNotesRtf(rt.Document);
                        }
In other words, the appended Rtf wasn't available until after being assigned to a RadRichTextEditor.  In my usage I am reading/writing Rtf to a database where it can displayed at a later time to the user.

 

Other code:

        private string GetPracticeNotesRtf(RadDocument practiceNotesDocument)
        {
            return practiceNotesDocument != null ? new RtfFormatProvider().Export(practiceNotesDocument) : string.Empty;
        }
        public RadDocument SetPracticeNotesRtf(string practiceNotes)
        {
            return !string.IsNullOrEmpty(practiceNotes) ? new RtfFormatProvider().Import(practiceNotes) : null;
        }

Thanks!

0
Dimitar
Telerik team
answered on 29 Jul 2020, 10:14 AM

Hi Larry,

I am glad that you have found a solution for your case. Do not hesitate to contact us if you have other questions.

Regards,
Dimitar
Progress Telerik

Tags
RichTextEditor
Asked by
Larry
Top achievements
Rank 1
Veteran
Answers by
Dimitar
Telerik team
Larry
Top achievements
Rank 1
Veteran
Share this question
or