This question is locked. New answers and comments are not allowed.
Hello,
I have a requirement to build a document generation engine and I'd like to know if it might be implemented with the RichTextBox. The idea is provide users, in the healtcare area, with document templates for fast full fill. A document template will contain;
Do you think these requirements may be implemented with RadRichTextBox, if so, any guide to start working?
Thanks
I have a requirement to build a document generation engine and I'd like to know if it might be implemented with the RichTextBox. The idea is provide users, in the healtcare area, with document templates for fast full fill. A document template will contain;
- read only fixed regions,
- read only dynamic regions (for example, patient info that will be filled dynamically depending on the patient)
- and dynamic regions to be filled by the user (typically a doctor). These region might contain free text provided by the user o "assisted text", for example a list of medicine to be supplied, a list of diagnoses... it woul be nice a feature similar to autocomplete, or suggestion list.
- a navigation tree to quickly access to the desired region
- my customer wishes a tool to generate these templates by medician experts
Do you think these requirements may be implemented with RadRichTextBox, if so, any guide to start working?
Thanks
10 Answers, 1 is accepted
0
Hello DanĂ,
Read-only regions can be implemented with document protection, as described in this help article and shown in this demo. For quick navigation around the document you can use bookmarks.
RadRichTextBox doesn't provide auto-complete and it is generally considered out of its scope, but you may come up with some custom solution, showing suggestions depending on the region containing current caret position.
Regards,
Boby
the Telerik team
Read-only regions can be implemented with document protection, as described in this help article and shown in this demo. For quick navigation around the document you can use bookmarks.
RadRichTextBox doesn't provide auto-complete and it is generally considered out of its scope, but you may come up with some custom solution, showing suggestions depending on the region containing current caret position.
Regards,
Boby
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Daní
Top achievements
Rank 1
answered on 30 Mar 2012, 10:19 AM
Hi Bobby,
Thanks for your response. But, still, I'm not sure if I can face these requirement using RichTextBox.
Thanks for your response. But, still, I'm not sure if I can face these requirement using RichTextBox.
- For AutoComplete or suggestion list feature, do you thin I can use Inline UI controls?
- One of the key points is the tool to generate dynamically new templates and editing existing ones. I imagine it as a Desig surface, where user can places "controls" (readonly text areas, medicines list control, diagnoses list controls, a "patient info" control that would load data dynamically depending on the current patien,...). Once the user submits his design, I should generate by code dynamically a RichTextBox document that would serve as document template.
I'd like to know what do you think (or purpose) about this approach and if you think about its viability in a reasonable time period (2-3 months).
Thanks
0
Hi DanĂ,
To your questions:
Kind regards,
Boby
the Telerik team
To your questions:
- The purpose of InlineUIContainers is to hold custom UI elements which act as document Inlines (you can find an image of document elements hierarchy here). Inlines display content that flows correctly in its parent paragraph. Maybe it should be better to use a popup or to customize the built-in context menu to show the suggestions. To mark the different regions (diagnoses, medicines), you can use custom annotations.
- RadRichTextBox can be used as a tool to generate such reports, as it is capable of creating bookmarks and document protections regions even with its built-in default UI. With regard to the custom annotations part, you can easily add some new tabs and buttons for dealing with them. Exporting to XAML will create the template which can be subsequently loaded by an instance of RadRichTextBox with different active user set to the property RadRichTextBox.CurrentUser.
You can also review our Mail Merge demo (and the help article here), which demonstrates document generation depending on the data source.
Kind regards,
Boby
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Daní
Top achievements
Rank 1
answered on 04 Apr 2012, 11:28 AM
Hi Booby,
I've seen MailMerge demo and I think merge fields can be very helpful. For instance, I think it'll be easier for me, and even for users, to create a view where users may edit the dynamic fields. Besides, I think I can generate a RadDocument template with the fixed paragraphs and use merge fields for the dynamic content. Once user submits the edition view, I can perform the document merge with the fullfilled data by the user and generate the final document. I think this approach maybe the easiest and the mos powerfull, as administrative users may edit the "template", modifying the fixed parts and customizing the final document appearance.
What is shown in the MailMerge demo is a very basic scenario. I don't know if I can use collection and nested properties as merge fields, can I?
Thanks
I've seen MailMerge demo and I think merge fields can be very helpful. For instance, I think it'll be easier for me, and even for users, to create a view where users may edit the dynamic fields. Besides, I think I can generate a RadDocument template with the fixed paragraphs and use merge fields for the dynamic content. Once user submits the edition view, I can perform the document merge with the fullfilled data by the user and generate the final document. I think this approach maybe the easiest and the mos powerfull, as administrative users may edit the "template", modifying the fixed parts and customizing the final document appearance.
What is shown in the MailMerge demo is a very basic scenario. I don't know if I can use collection and nested properties as merge fields, can I?
Thanks
0
Daní
Top achievements
Rank 1
answered on 05 Apr 2012, 09:00 AM
Hi after some research and testing of some of the RadRcihTexBox features, I think that merge fields can fit really fine to my requirements. In summary, by approach will be formed by 3 steps:
I have performed some testing with merge fields. They work fine when underlying properties are string typed. Unfortunately, my view model class is a bit more complex. It contains, basically, string properties (no matter with these), object collections (I'd like they being merged as tables), and rich text properties (user fullfills some data in the fullfilment form wiht RadRichTextBoxs, using XamlDataProvider for binding, causes that when merging these properties the documents contains the xaml text, not the formatted result).
So, I'd like to know if there is any extension/customization method for merge fields that allows to supply the formatted result for a property type.
Thanks.
- Template generation: an specialized user, will generate the document template, adding fixed text areas, headers, footers... And also providing dynamic merge fields. To do this task, I'll provide a user interface very similar to the TelerikEditor demo. The template wiil be saved at server as .xaml file.
- Data fullfill: users, normally doctors, wiil have to fullfill a custom form, a Silverlight User control, with visual elements bounds to the properties of view model object instance.
- Once the data form fullfill is completed and users submits it, the application will download the .xaml template form server and will merge fields against the view model instance to generate the final document.
I have performed some testing with merge fields. They work fine when underlying properties are string typed. Unfortunately, my view model class is a bit more complex. It contains, basically, string properties (no matter with these), object collections (I'd like they being merged as tables), and rich text properties (user fullfills some data in the fullfilment form wiht RadRichTextBoxs, using XamlDataProvider for binding, causes that when merging these properties the documents contains the xaml text, not the formatted result).
So, I'd like to know if there is any extension/customization method for merge fields that allows to supply the formatted result for a property type.
Thanks.
0
Daní
Top achievements
Rank 1
answered on 05 Apr 2012, 11:33 AM
I think I can solve all my obstacles. I have just created several custom merge fields classes, inheriting from MergeField class. Just overriding some MergeField members (FieldTypeName, CreateInstance and GetResultFragment) and then registering these field types with CodeBasedFieldFactory.RegisterFieldType allows me to customize the merging feature. I have created a custom "Insert Merge Field" RibbonDropDownButton for the RichtTextBox RibbonView that allows me to create/modify templates using the custom fields and everything works like a charm.
Wow, RadRichTextBox offers really a lot of useful features. However, it's a bit difficult to delve with all richtextbox feature because is a really huge control and, sometimes, is difficult to find precise information.
Wow, RadRichTextBox offers really a lot of useful features. However, it's a bit difficult to delve with all richtextbox feature because is a really huge control and, sometimes, is difficult to find precise information.
0
Hello DanĂ,
I was about to point you to the answer in this forum thread, containing a demo project demonstrating the usage of custom merge fields, but it looks you manage to implement such already. The built-in merge fields internally uses Binding objects, so you can use the familiar property path syntax.
We are constantly working on improving the documentation, so if you have any specific suggestions for its improvement or have found any omissions, we'd be glad if you share them with us.
All the best,
Boby
the Telerik team
I was about to point you to the answer in this forum thread, containing a demo project demonstrating the usage of custom merge fields, but it looks you manage to implement such already. The built-in merge fields internally uses Binding objects, so you can use the familiar property path syntax.
We are constantly working on improving the documentation, so if you have any specific suggestions for its improvement or have found any omissions, we'd be glad if you share them with us.
All the best,
Boby
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Daní
Top achievements
Rank 1
answered on 09 Apr 2012, 09:30 AM
Hello Bobby
I don't have any complaint about documentation. I assume that, fortunately, telerik's toolset is constantly growing up and that new features are being added to existing controls, besides, some controls like GridView and RichTextBox are rully huge, so it's difficult to keep documentation up to date. Of course, everything can be improved and telerik's documentation is not an exception, but the the lack of documentation in some features is compensated with a great support in this forum, support tickets... so, in average, I'm quite satisfied with telerik's support.
I don't have any complaint about documentation. I assume that, fortunately, telerik's toolset is constantly growing up and that new features are being added to existing controls, besides, some controls like GridView and RichTextBox are rully huge, so it's difficult to keep documentation up to date. Of course, everything can be improved and telerik's documentation is not an exception, but the the lack of documentation in some features is compensated with a great support in this forum, support tickets... so, in average, I'm quite satisfied with telerik's support.
0
Daní
Top achievements
Rank 1
answered on 09 Apr 2012, 10:05 AM
Hello,
Once I've solved merge fields customization, I need to supply a RadDocumentFragment in GetResultFragment method for each custmo merge field. Of course, I can generate the RadDocumentFragment by adding RichTextBox elements (paragraphs, sections, borders, tables,...) by code. But it would be easier for me to design DataTemplates or User Controls to be added to RadRichTextBox inside an InlineUIContainer. In my first attemp, to avoid to generate a Table programatically, I've tried to add a RadGridView inside an InlineUIContainer. So what I've tried is:
Unfortunately, when printing or saving the final document, nothing appears.
To summarize what I'm doing, i hace to say that finall RadRichTextBox is created on the fly, When user submits the edition form, I create a RichTextBox in the fly preloaded with the ".xaml document template", then I supply the mail merge items source and call the MailMerge method. MailMerge Methods causes that all dynmic fields being calculated, so GetResultFragment method is called. Finally, I'm calling the Print method on RichTextBox.
so, can i supply DataTemplates (or UserControls) when merging fields to easyly design the finall content?
Thanks
Once I've solved merge fields customization, I need to supply a RadDocumentFragment in GetResultFragment method for each custmo merge field. Of course, I can generate the RadDocumentFragment by adding RichTextBox elements (paragraphs, sections, borders, tables,...) by code. But it would be easier for me to design DataTemplates or User Controls to be added to RadRichTextBox inside an InlineUIContainer. In my first attemp, to avoid to generate a Table programatically, I've tried to add a RadGridView inside an InlineUIContainer. So what I've tried is:
- I've created a DataTemplate with a RadGridView where I've defined the desired columns.
- In the inherited MergeField class, in GetResultFragment override method, I obtain, via propertypath, a collection of items.
- Then, I instantiate a RadRichTextBox on the fly. I also instantiate a ContentPresenter control setting the items collection as the Content property and the DataTemplate as the ContentTemplate.
- I've added a InlineUIContainer to the RadRichTextBox containing the ContentControl.
- Finally, I've called RadRichTextBox.Document.Selection.SelecAll() method and I'm returning the DocumentFragment by calling CopySelectedDocumentsElements method.
Unfortunately, when printing or saving the final document, nothing appears.
To summarize what I'm doing, i hace to say that finall RadRichTextBox is created on the fly, When user submits the edition form, I create a RichTextBox in the fly preloaded with the ".xaml document template", then I supply the mail merge items source and call the MailMerge method. MailMerge Methods causes that all dynmic fields being calculated, so GetResultFragment method is called. Finally, I'm calling the Print method on RichTextBox.
so, can i supply DataTemplates (or UserControls) when merging fields to easyly design the finall content?
Thanks
0
Hello DanĂ,
I am not sure I understand your implementation well. Are you using an instance of RadRichTextBox just to create a document fragment?
You should also note that serialization (saving) of the content of the InlineUIContainers is not always possible, especially for complex controls such as RadGridView. In addition, customization of the export process cannot be achieved with the current version (we are planning to expose InlineUIContainerExporting event similar to the one found in HtmlExportSettings, but this is not scheduled yet).
Here is a sample implementation of GetResultFragment for custom merge field returning document fragment containing RadGridView:
which is modified part of the sample project found here; but it won't work in your case either, as XamlReader cannot successfully load the RadGridView serialized on document export.
As a general rule, we suggest using InlineUIContainer only in much simpler cases, and in your scenario it's probably better to use the document model.
Regards,
Boby
the Telerik team
I am not sure I understand your implementation well. Are you using an instance of RadRichTextBox just to create a document fragment?
You should also note that serialization (saving) of the content of the InlineUIContainers is not always possible, especially for complex controls such as RadGridView. In addition, customization of the export process cannot be achieved with the current version (we are planning to expose InlineUIContainerExporting event similar to the one found in HtmlExportSettings, but this is not scheduled yet).
Here is a sample implementation of GetResultFragment for custom merge field returning document fragment containing RadGridView:
protected
override
DocumentFragment GetResultFragment()
{
Customer customer =
this
.Document.MailMergeDataSource.CurrentItem
as
Customer;
if
(customer ==
null
)
{
return
null
;
}
if
(
this
.PropertyPath ==
"Orders"
)
{
RadDocument document = CreateDocumentWithRadGridView(customer);
return
new
DocumentFragment(document);
}
return
null
;
}
private
RadDocument CreateDocumentWithRadGridView(Customer customer)
{
RadGridView gridView =
new
RadGridView()
{
ItemsSource = customer.Orders
};
Paragraph paragraph =
new
Paragraph();
paragraph.Inlines.Add(
new
InlineUIContainer(gridView,
new
System.Windows.Size(gridView.ActualWidth, gridView.ActualHeight)));
Section section =
new
Section();
section.Blocks.Add(paragraph);
RadDocument document =
new
RadDocument();
document.Sections.Add(section);
document.MeasureAndArrangeInDefaultSize();
return
document;
}
As a general rule, we suggest using InlineUIContainer only in much simpler cases, and in your scenario it's probably better to use the document model.
Regards,
Boby
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>