Products Technologies Demo Docs Blog Support Company

TextControl.Web: Custom Mail Merge Preview

In a recent blog entry, we explained how to add custom code to ribbon buttons and how to cancel the event bubbling. This works for the majority of buttons, but doesn't work for the Preview Merge Results button, because of an anonymous Javascript function. In this case, the complete node must be cloned to remove the event handlers. Then, all the required events can be rewired. The following code uses jQuery to store the parent node, clone the button and to append it to the parent element.…

TextControl.Web: Custom Mail Merge Preview

In a recent blog entry, we explained how to add custom code to ribbon buttons and how to cancel the event bubbling. This works for the majority of buttons, but doesn't work for the Preview Merge Results button, because of an anonymous Javascript function.

In this case, the complete node must be cloned to remove the event handlers. Then, all the required events can be rewired. The following code uses jQuery to store the parent node, clone the button and to append it to the parent element.

<script>
        // wait until the complete ribbon is loaded
        TXTextControl.addEventListener("ribbonTabsLoaded", function (e) {
                attachEvents();
        });

        function attachEvents() {
                // store the parent element
                var parent = $("#tglBtnPreviewMergeResults").parent();
                // clone and append the element to the parent
                $("#tglBtnPreviewMergeResults").clone().appendTo(parent);
                // remove the old element
                $("#tglBtnPreviewMergeResults").remove();
                // rewire required events
                $(document).on("click", "#tglBtnPreviewMergeResults",
                        function () {
                                alert("Custom Preview");
                        });
        }
</script>

Happy coding!

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Reporting

The Text Control Reporting Framework combines powerful reporting features with an easy-to-use, MS Word compatible word processor. Users can create documents and templates using ordinary Microsoft Word skills. The Reporting Framework is included in all .NET based TX Text Control products including ASP.NET, Windows Forms and WPF.

See Reporting products

Related Posts

ASP.NETReportingHTML5

Creating Your First ASP.NET Reporting Application

This tutorial shows how to use the MailMerge component in an ASP.NET Web application to merge a template with data to create an Adobe PDF document.


ASP.NETReportingAuto Save

Automatically Reconnect to the Server and Recover the Document

We just published a sample project that shows how to reconnect to the server and how to recover the current document.


ReportingHTML5Widget

JavaScript API: Working with Merge Fields

This article gives an overview of how to add, remove and manipulate merge fields programmatically using the JavaScript API.


AngularJavaScriptReact

Technology Preview: Embeddable HTML Widget to integrate Document Editing to…

This technology preview shows an early version of an HTML widget that can be embedded into any HTML page.


AngularReportingHTML5

Embedding TXTextControl.Web in non-.NET Framework applications like .NET…

This article shows how to embed the ASP.NET MVC component TXTextControl.Web into non-.NET Framework applications.