6 Answers, 1 is accepted
0
Hello Rob,
We couldn't reproduce the described behavior. Can you give us more details on your scenario or even better - open a support ticket with a simple working demo project illustrating the issue.
All the best,
Mihail
the Telerik team
We couldn't reproduce the described behavior. Can you give us more details on your scenario or even better - open a support ticket with a simple working demo project illustrating the issue.
All the best,
Mihail
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0
Rob
Top achievements
Rank 1
answered on 18 Mar 2013, 02:41 PM
Hello Mihail,
I think the problem has something to do with inserting the field with FieldDisplayMode = "Result" instead of "Code". Please see the following project which demonstrates the two methods:
I think the problem has something to do with inserting the field with FieldDisplayMode = "Result" instead of "Code". Please see the following project which demonstrates the two methods:
<
UserControl
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
x:Class
=
"SilverlightApplication70.MainPage"
>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"White"
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"1*"
/>
</
Grid.RowDefinitions
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"1*"
/>
<
ColumnDefinition
Width
=
"1*"
/>
</
Grid.ColumnDefinitions
>
<!-- Data -->
<
ListBox
Grid.Row
=
"0"
Grid.ColumnSpan
=
"2"
ItemsSource
=
"{Binding Items}"
>
<
ListBox.ItemTemplate
>
<
DataTemplate
>
<
TextBox
Text
=
"{Binding TextProperty, Mode=TwoWay}"
AcceptsReturn
=
"True"
/>
</
DataTemplate
>
</
ListBox.ItemTemplate
>
</
ListBox
>
<!-- Insert As Code And Then Merge -->
<
StackPanel
Grid.Row
=
"1"
Grid.Column
=
"0"
>
<
Button
Content
=
"Insert Merge Field As Code"
Click
=
"btn_InsertAsCode"
/>
<
Button
Content
=
"Perform Merge"
Click
=
"btn_Merge"
/>
<
telerik:RadRichTextBox
x:Name
=
"rtb1"
/>
<
telerik:RadRichTextBox
x:Name
=
"rtb2"
/>
</
StackPanel
>
<!-- Insert Directly As Result -->
<
StackPanel
Grid.Row
=
"1"
Grid.Column
=
"1"
>
<
Button
Content
=
"Insert Merge Field As Result"
Click
=
"btn_InsertAsResult"
/>
<
telerik:RadRichTextBox
x:Name
=
"rtb3"
/>
</
StackPanel
>
</
Grid
>
</
UserControl
>
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using Telerik.Windows.Documents.Model;
namespace SilverlightApplication70
{
public partial class MainPage : UserControl
{
public MyDataContext dc = new MyDataContext();
public MainPage()
{
InitializeComponent();
dc.Items = new List<
MyDataObject
>()
{
new MyDataObject()
{
TextProperty = "START1\nLorem ipsum dolor sit amet, consectetur adipiscing elit.\nMauris sit amet risus elit.\nDonec ullamcorper aliquam elit commodo accumsan.\nEND1"
},
new MyDataObject()
{
TextProperty = "START2\nVivamus dapibus varius augue non rutrum.\nMorbi in iaculis mauris.\nEND2"
},
new MyDataObject()
{
TextProperty = "START3\nDonec congue sagittis libero, commodo imperdiet leo tempus a.\nEND3"
},
};
this.DataContext = dc;
this.rtb1.Document.MailMergeDataSource.ItemsSource = dc.Items;
this.rtb3.Document.MailMergeDataSource.ItemsSource = dc.Items;
}
private void btn_InsertAsCode(object sender, RoutedEventArgs e)
{
this.rtb1.ActiveDocumentEditor.InsertField
(
new MergeField()
{
PropertyPath = "TextProperty"
},
FieldDisplayMode.Code
);
}
private void btn_Merge(object sender, RoutedEventArgs e)
{
this.rtb2.Document = this.rtb1.MailMergeCurrentRecord();
}
private void btn_InsertAsResult(object sender, RoutedEventArgs e)
{
this.rtb3.ActiveDocumentEditor.InsertField
(
new MergeField()
{
PropertyPath = "TextProperty"
},
FieldDisplayMode.Result
);
}
}
public class MyDataObject
{
public string TextProperty
{
get;
set;
}
}
public class MyDataContext : INotifyPropertyChanged
{
private List<
MyDataObject
> _Items;
public List<
MyDataObject
> Items
{
get
{
return _Items;
}
set
{
_Items = value;
RaisePropertyChanged("Items");
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(string propertyName)
{
var propertyChanged = PropertyChanged;
if ((propertyChanged != null))
{
propertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
0
Hello Rob,
Iva Toteva
the Telerik team
Actually the problem is that you have new lines (paragraphs) and not line breaks. Multiple paragraphs in the result of a mail merge field are not thoroughly supported. We will revise the logic and try to implement it for the upcoming service pack or soon after that.
Iva Toteva
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0
Sergi
Top achievements
Rank 1
answered on 07 May 2013, 02:52 PM
Hello Iva,
I'm using the merge fields in RichTextBox also, I try to merge data with \n, \n\r, CHR(13), CHR(10) and <br> but when I try merge the document is still merged in one line. What can I do to have a multiline merge field?
Thanks,
Sergi
I'm using the merge fields in RichTextBox also, I try to merge data with \n, \n\r, CHR(13), CHR(10) and <br> but when I try merge the document is still merged in one line. What can I do to have a multiline merge field?
Thanks,
Sergi
0
Hi Sergi,
Iva Toteva
the Telerik team
This improvement has not been implemented yet. You can check the solution with custom merge field included in this forum thread. The first example is for WPF, but the last post includes an example for Silverlight.
Iva Toteva
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0
Lawrence
Top achievements
Rank 2
Iron
answered on 22 Aug 2013, 06:24 PM
This is a bit of a "hack/ghetto" solution, and I have only verified it with WPF. I ran across this article that described a special character causing a line break. In my case, I have an Address1 and Address2 fields. If Address2 is not null or empty, then I want to show it on my merge document, otherwise don't. If I use a separate merge field, I would have an empty line, not good.
The special character is "¬".
The special character is "¬".
const
string
LineBreakSymbol =
"¬"
;
if
(!
string
.IsNullOrWhiteSpace(
this
.Address2))
{
this
.AddressCombined =
string
.Format(
"{0}{1}{2}"
,
this
.Address1, LineBreakSymbol,
this
.address2);
}
else
{
this
.AddressCombined =
this
.Address1;
}