Underline a character in the item text

11 Apr 20222 minutes to read

Underline a particular character in a text can be handled in beforeItemRender event by adding <u> tag in between the text and given as innerHTML in li rendering.

In the following example, C is underlined in the text Copy.

<ejs-dropdownbutton id="ddbtn" items="ViewBag.items" content="Clipboard" beforeItemRender="itemRender"></ejs-dropdownbutton>

<script>
function itemRender(args){
    if (args.item.text === 'Copy') {
        // To underline a particular text.
        args.element.innerHTML = '<u>C</u>opy';
    }
}
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Syncfusion.EJ2.Buttons;
namespace EJ2CoreSampleBrowser.Controllers.Button
{
    public partial class ButtonController : Controller
    {
        public ActionResult DropDownButton()
        {
            List<object> items = new List<object>();
            items.Add(new
            {
                text = "Cut"
            });
            items.Add(new
            {
                text = "Copy"
            });
            items.Add(new
            {
                text = "Paste"
            });
            ViewBag.items = items;
            return View();
        }
    }
}