Products Technologies Demo Docs Blog Support Company

HTML5: Make Merge Field Lists Scrollable in the Ribbon Bar

It is recommended to provide a view for the available merge fields in the MAILINGS ribbon tab which is essentially the most important tab when it comes to the creation of mail merge templates. But sometimes, a table has simply a lot of fields and the available height for the merge field list is limited. This sample shows how easy it is to customize the ribbon bar and the basic HTML elements such as an unordered list. The following Javascript / jQuery is all you need to make the last level of…

HTML5: Make Merge Field Lists Scrollable in the Ribbon Bar

It is recommended to provide a view for the available merge fields in the MAILINGS ribbon tab which is essentially the most important tab when it comes to the creation of mail merge templates.

But sometimes, a table has simply a lot of fields and the available height for the merge field list is limited. This sample shows how easy it is to customize the ribbon bar and the basic HTML elements such as an unordered list.

HTML5: Make merge field lists scrollable in the ribbon

The following Javascript / jQuery is all you need to make the last level of the dropdown menu scrollable:

var interval;

// after the complete ribbon is loaded, "listen" to the
// "Insert Merge Field" drop-down to see whether the
// database is loaded completely
TXTextControl.addEventListener("ribbonTabsLoaded", function (e) {
    interval = setInterval(SetScrollbars, 500);
});

// if button doesn't have the "disabled" class anymore
function SetScrollbars() {
    if (!$("#drpDnBtnInsertMergeField").hasClass("ui-state-disabled")) {

        clearInterval(interval);

        // find the last "ul" element and set the height and
        // overflow properties
        $("#insertMergeFieldDropDown").find("li").each(function () {
            $(this).find("ul").last().css({
                "max-height": "150px",
                "overflow-y": "scroll",
                "width": $(this).width() + 50
            });
        });
    }
};

After the complete ribbon structure is loaded, the dropdown button Insert Merge Field is monitored until it is enabled. This implies that the database is loaded completely.

When loaded, all li elements of the dropdown button element are iterated. For each list element, the last ordered list element (<ul></ul>) is used to make CSS changes. This element is the list where all available merge fields are listed.

The maximum height and the overflow behavior is adjusted to enable the scrollbars when required. Additionally, the width is increased to make some more space for the additional scrollbar.

Download the sample from GitHub and test it on your own.

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

GitHub

Download and Fork This Sample on GitHub

We proudly host our sample code on github.com/TextControl.

Please fork and contribute.

Download ZIP

Open on GitHub

Open in Visual Studio

Requirements for this sample

  • Visual Studio 2012 or better
  • TX Text Control .NET Server (trial sufficient)

ASP.NET

Integrate document processing into your applications to create documents such as PDFs and MS Word documents, including client-side document editing, viewing, and electronic signatures.

ASP.NET Core
Angular
Blazor
JavaScript
React
  • Angular
  • Blazor
  • React
  • JavaScript
  • ASP.NET MVC, ASP.NET Core, and WebForms

Learn more Trial token Download trial

Related Posts

ASP.NETReportingGitHub

ASP.NET MVC: Implementing a Simplistic, Custom Button Bar

For some applications, the fully-featured ribbon bar might be too overloaded with features or the ribbon concept is not required in a project. Programmatically, all ribbon tabs, groups and buttons…


ASP.NETReportingGitHub

ASP.NET MVC: Adding Protected Sections to Documents

A SubTextPart object represents a user-defined range of text in a TX Text Control document. A SubTextPart is basically a range of text with a Name and an ID property to store additional…


ASP.NETReportingElectronic Signature

ASP.NET: Adding Electronic Signatures to Documents

An electronic signature is in many processes legally sufficient to prove an identity. According to the U.S. Federal ESIGN Act passed in 2000, an electronic signature is an: Electronic sound,…


ASP.NETGitHubHTML5

MVC: Loading Files from the Backstage Menu

Happy New Year, everybody! In the last blog entry, we showed how to replace the file menu with an MS Word-style backstage menu. This project shows how to load documents from a partial view in the…


ASP.NETGitHubHTML5

MVC: Replace the File Menu with a Backstage View Menu

Microsoft Word provides a very smart way to manage documents and related data such as metadata and personal information in a separate view: The backstage view. The ribbon bar contains commands for…