Hi Telerik team,
We are evaluating your RichTextBox and MailMerge functionality in order to display read-only views.
Some questions had arisen we would like to address to you:
We use our own Condiational MergeFields to hide, for example, a paragraph if the value of a Mergefield is empty. This is relevant in label-value situations where you, in addition to the empty value field, want to hide the Label. The paragraphs with conditional MergeFields are removed after loading the document. However, this procedure requires the reload of the document after a MailMergeDataSource change. Do you have a different approach to implement this behavior, perhaps to hide a section or paragraph instead of removing?
public static class ConditionalMergeFields
{
public static void RemoveEmptyMergeFields(RadDocument document)
{
foreach (var section in document.Sections)
{
// enumerate paragraphs which contain empty ConditionalMergeFields
foreach (var paragraph in section.EnumerateChildrenOfType<Paragraph>().ToList()
.Where(paragraph => paragraph.EnumerateChildrenOfType<FieldRangeStart>()
.Any(f => f.Field is IConditionalMergeField && ((IConditionalMergeField) f.Field).IsEmpty)))
{
section.Blocks.Remove(paragraph);
}
}
}
}
In order to implement lists and 1:n relationships in Richtext Templates we use custom List MergeFields. In the overloaded GetResultFragment method a new RadDocument is created, mailmerged and returned as DocumentFragment. As the amount of List items grows, the MailMerge method of the RadDocument consumes some time (4 times about 1.2 seconds). Would you suggest a different approach?
protected override DocumentFragment GetResultFragment()
{
var subList = getList();
var document = (RadDocument)SubDataDocument.CreateDeepCopy();
document.MailMergeDataSource.ItemsSource = subList;
ConditionalMergeFields.RemoveEmptyMergeFields(document);
document.ChangeAllFieldsDisplayMode(FieldDisplayMode.Result);
document.MailMergeDataSource.MoveToFirst();
if (subList.Count > 1)
{
document = document.MailMerge(false);
}
if (document.Sections.First.Headers != null && document.Sections.First.Headers.Default != null && document.Sections.First.Headers.Default.Body != null)
{
document.Sections.AddBefore(document.Sections.First,
(Section)document.Sections.First.Headers.Default.Body.Sections.First.CreateDeepCopy());
}
return new DocumentFragment(document);
}
Text Styling like font size and font color are specified to a predetermined value in the RadDocument Template. Is there a way to bind them to application resources in order to style and change them on the fly? StaticResource is not working since the XamlFormatProvider does not find the Resource during the XAML parse Process.
Thank you in advance,
Wolfgang