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

Using multiple Dataset in Editor

2 Answers 84 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Vitall
Top achievements
Rank 1
Vitall asked on 24 May 2013, 06:30 AM
Hello,
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);
this.radRichTextBox.ChangeAllFieldsDisplayMode(FieldDisplayMode.Result);
}
 
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
                };
                count++;
                fieldButton.Command = this.radRichTextBox.Commands.InsertFieldCommand;
                fieldButton.CommandParameter = new MergeField { PropertyPath = fieldName };
                stackPanel.Children.Add(fieldButton);
            }
            grid.Height = count;
            stackPanel.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            scrollViewer.Content = stackPanel;
            grid.Children.Add(scrollViewer);
            radRibbonDropDownButton.DropDownContent = grid;
        }

2 Answers, 1 is accepted

Sort by
0
Vitall
Top achievements
Rank 1
answered on 24 May 2013, 11:15 AM
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)
 
0
Petya
Telerik team
answered on 28 May 2013, 02:04 PM
Hello,

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.

Regards,
Petya
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
RichTextBox
Asked by
Vitall
Top achievements
Rank 1
Answers by
Vitall
Top achievements
Rank 1
Petya
Telerik team
Share this question
or