AppendDocument not giving expected results?

4 posts, 0 answers
  1. Larry
    Larry avatar
    2 posts
    Member since:
    May 2020

    Posted 27 Jul Link to this post

    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?

  2. Dimitar
    Admin
    Dimitar avatar
    2907 posts

    Posted 28 Jul Link to this post

    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

  3. Larry
    Larry avatar
    2 posts
    Member since:
    May 2020

    Posted 28 Jul in reply to Dimitar Link to this post

    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!

  4. Dimitar
    Admin
    Dimitar avatar
    2907 posts

    Posted 29 Jul Link to this post

    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

Back to Top