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
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;
}