We just added a new interactive sample to our online demos that shows how to create your first report using TX Text Control. The idea to show the process of creating a document step by step beginning with preparing the data, creating the template to merging them together.

In the first step, JSON sample data is loaded into a JSON editor that can modified for testing purposes. Each time, data is changed in the editor, the drop-down boxes in the editor (step 2) are updated using the following code:

editor.getSession().on('change', function () {
try {
$("#editor").notify("Data model updated!", { className: "success" });
var jsonData = editor.getValue();
JSON.parse(jsonData);
TXTextControl.loadJsonData(jsonData);
} catch (e) {
return false;
}
});
view raw test.js hosted with ❤ by GitHub

Preparing data

In step 2, the editor can be used to create a template. Use it to insert static text, headers and footers and other word processing elements into the template. Using the Insert Merge Field and Insert Merge Block buttons, merge fields and blocks associated to the connected data can be added.

Preparing the template

When the template is ready, the button Merge Template can be used to merge the template with the created data. The created document is then loaded into the DocumentViewer.

Merging the document

Test this demo on your own and create your first report using TX Text Control:

Launch demo