Using multiple Dataset in Editor

3 posts, 0 answers
  1. Vitall
    Vitall avatar
    7 posts
    Member since:
    Apr 2013

    Posted 24 May 2013 Link to this post

    I want to use multiple Dataset on my Telerik Editor (RichTextBox). Let me explain in steps, Firstly i created another "Insert Merge Filed" button and populate 2nd Dataset data. In the second step, drop Merge fields related to both Dataset (Insert Merge Filed and Insert Merge Filed 2) on letter and then simply save. Now problem get started when i open saved letter and wanna to view the Merge fields data on load not on click Preview results. When I put  this line of code  "this.radRichTextBox.ChangeAllFieldsDisplayMode(FieldDisplayMode.Result)"  on letter load, Merge fields related to one data set  load not other Dataset.
    Here is my code 

    void Page1_Loaded(object sender, RoutedEventArgs e)
    ds = letterservice.ExecuteTag("SearchPatient", new System.Collections.Generic.KeyValuePair<string, object>[] { new  System.Collections.Generic.KeyValuePair<string, object>("@0", 135) });
    AddMergeFieldsInDropDownContent(this.btnModule, ds);                   
    ds = letterservice.ExecuteTag("SearchPatientImmunization", new System.Collections.Generic.KeyValuePair<string, object>[] { new  System.Collections.Generic.KeyValuePair<string, object>("@0", 8) });
    AddMergeFieldsInDropDownContent(this.btnSubModule, ds);
    private void AddMergeFieldsInDropDownContent(RadRibbonDropDownButton radRibbonDropDownButton, DataSet ds)
                Grid grid = new Grid();
                int count = 200;
                //grid.Height = 400;
                ScrollViewer scrollViewer = new ScrollViewer();
                scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
                StackPanel stackPanel = new StackPanel();
                this.DataContext = this;
                this.radRichTextBox.Document.MailMergeDataSource.ItemsSource = ds.Tables[0].DefaultView;
                foreach (string fieldName in this.radRichTextBox.Document.MailMergeDataSource.GetColumnNames())
                    RadRibbonButton fieldButton = new RadRibbonButton
                        Text = fieldName,
                        Size = ButtonSize.Medium,
                        HorizontalAlignment = HorizontalAlignment.Stretch,
                        HorizontalContentAlignment = HorizontalAlignment.Left
                    fieldButton.Command = this.radRichTextBox.Commands.InsertFieldCommand;
                    fieldButton.CommandParameter = new MergeField { PropertyPath = fieldName };
                grid.Height = count;
                stackPanel.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                scrollViewer.Content = stackPanel;
                radRibbonDropDownButton.DropDownContent = grid;
  2. Vitall
    Vitall avatar
    7 posts
    Member since:
    Apr 2013

    Posted 24 May 2013 Link to this post

    like in the given scenario, student have one to many relation with the subjects table like any student can enrolled in more then one course. So my case is simple i wanna to print Raddocument with two data sets e.g one related to students and other load particular student data (one or many rows)
  3. Petya
    Petya avatar
    983 posts

    Posted 28 May 2013 Link to this post


    I am having a hard time understanding what exactly you are trying to achieve.

    Generally, a document can only be associated with a single item's source. I am not sure what is the workflow of your application, but it seems that you export a document which contains merge fields and respective data in the item's source is available only for some of them. Note that in order for the fields to show results when the document is imported back, the source should also be present, so this might be the cause of the issue you are facing.

    That said, I suggest you create an appropriate for your application's logic class that can hold all properties. You can try using ExpandoObject in order to create the objects on the fly if needed. Alternatively, you can refer to this forum thread where advanced mail-merge scenarios have been discussed for a reference on how to create a custom merge field.

    I hope this is helpful! Let us know if you have other questions.


    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top