Integrated template workflow
Design beside the document
The assistant is attached to the editor itself. Open it from the new Template Assistant group on the Reporting ribbon or use the button below.
One guided workspace
From JSON to template
Load data, insert fields, create nested blocks, and store data-shaping rules without covering the document.
Reporting
JSONFieldsBlocksRules
Try this
Build a useful template
- Insert a root customer field.
- Add an order-detail merge block.
- Sort or filter its rows.
- Preview the merged result.
Ready to tryUse the controls above to interact with this demo.
What this demonstrates
An application-owned reporting assistant
The editor remains the document canvas while the surrounding application contributes a focused template-design experience. The assistant reads JSON in the browser, inserts real TX Text Control fields and blocks, and stores the selected rules in the template.
Key members
Connect uploaded JSON
TXTextControl.loadJsonData
Insert a field
TXTextControl.addMergeField
Send the current template
TXTextControl.saveDocument
Generate nested blocks
DataSourceManager.InsertMergeBlock
Style generated tables
TableCell.CellFormat
Explain the live template
TemplateAnalyzer.Analyze
Why the assistant belongs inside the editor
Template authors need to see the insertion position and the surrounding document while choosing data. The fly-in panel overlaps the editor instead of resizing it, so the document keeps its exact layout. A custom ribbon group makes the application feature feel like a natural extension of the Reporting workflow.
const field = new TXTextControl.MergeField();
field.name = fieldPath;
field.text = `«${fieldPath}»`;
TXTextControl.addMergeField(field);
Blocks and data shaping are template metadata
MergeBlockInfo describes the selected columns and nested ChildBlocks. Its SortingInstructions, Filters, and BlockMergingCondition are stored with the generated txmb_ subtextparts. The server inserts that hierarchy directly into the current template so its relationships remain intact. When MailMerge.MergeJsonData processes the document, those rules are evaluated automatically.
var info = new MergeBlockInfo(design.Name) {
ColumnNames = design.Fields,
ChildBlocks = design.Children.Select(CreateMergeBlockInfo).ToList(),
SortingInstructions = [new SortingInstruction("OrderQty", SortOrder.Descending)]
};
manager.InsertMergeBlock(
textControl,
info,
new MergeBlockSettings(BlockTemplateType.TableRow, createHeaderRow: true));
Presets separate structure from presentation
Each txmb_ block has its own text context. The server activates each block and resolves its table with Tables.GetItem. Merged-cell continuation entries have a negative Length and are skipped. For every real cell, background, spacing, and text formatting are applied first; border widths and colors must be applied last so later TableCellFormat changes cannot overwrite them.
textControl.Select(block.Start, 0);
var table = textControl.Tables.GetItem();
foreach (TableCell cell in table.Cells)
{
if (cell.Length < 0) continue;
cell.CellFormat.BackColor = cell.Row == 1
? preset.HeaderColor
: preset.BodyColor;
cell.CellFormat.LeftTextDistance = preset.CellPadding;
cell.CellFormat.RightTextDistance = preset.CellPadding;
ApplyBorders(cell.CellFormat, preset.BorderColor, preset.BorderWidth);
}