Search results

Popup items

Icons

The popup action item have an icon or image to provide visual representation of the action. To place the icon on a popup item, set the iconCss property to e-icons with the required icon CSS. By default, the icon is positioned to the left side of the popup action item.

In the following sample, the icons for edit, delete, mark as read and like message menu items are added using the iconCss property.

razor
popupicons.cs
@section ControlsSection{

   @Html.EJS().DropDownButton("left-icon").Content("Message").Items((IEnumerable<object>)ViewBag.items).IconCss("ddb-icons e-message").Render()

}

<style>
    /* csslint ignore:start */
    @font-face {
        font-family: 'e-db-icons';
        src:
        url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAAKAIAAAwAgT1MvMj0jSRoAAAEoAAAAVmNtYXDnFudgAAABkAAAADpnbHlmSrKTCAAAAdgAAAC4aGVhZBKtK8cAAADQAAAANmhoZWEHmQNtAAAArAAAACRobXR4D7gAAAAAAYAAAAAQbG9jYQB4ADoAAAHMAAAACm1heHABEAAYAAABCAAAACBuYW1lH00mDAAAApAAAAJJcG9zdIwkSr0AAATcAAAATQABAAADUv9qAFoEAAAA//4D6gABAAAAAAAAAAAAAAAAAAAABAABAAAAAQAAGc/PS18PPPUACwPoAAAAANfSc3wAAAAA19JzfAAAAAAD6gPqAAAACAACAAAAAAAAAAEAAAAEAAwAAgAAAAAAAgAAAAoACgAAAP8AAAAAAAAAAQPuAZAABQAAAnoCvAAAAIwCegK8AAAB4AAxAQIAAAIABQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUGZFZABA5wPnBQNS/2oAWgPqAJYAAAABAAAAAAAABAAAAAPoAAAD6AAAA+gAAAAAAAIAAAADAAAAFAADAAEAAAAUAAQAJgAAAAQABAABAADnBf//AADnA///AAAAAQAEAAAAAQACAAMAAAAAAAAAHAA6AFwAAAACAAAAAAPqA2UABgAKAAA3IREjCQEjBRcBIQID6AL+Dv4NAQEY3QG4/I+IAsL+GAHonroBcwAAAAIAAAAAA8YD6gAFAAoAADchESMJASUHCQImA6AD/jL+MQEEywGWAZb+agICX/4+AcLXsv6cAWQBZAAAAAEAAAAAA+oD6gALAAATCQEXCQE3CQEnCQECATP+zcIBMgEzwf7OATLB/s3+zgMp/s3+zsIBM/7NwgEyATPB/s4BMgAAAAASAN4AAQAAAAAAAAABAAAAAQAAAAAAAQAKAAEAAQAAAAAAAgAHAAsAAQAAAAAAAwAKABIAAQAAAAAABAAKABwAAQAAAAAABQALACYAAQAAAAAABgAKADEAAQAAAAAACgAsADsAAQAAAAAACwASAGcAAwABBAkAAAACAHkAAwABBAkAAQAUAHsAAwABBAkAAgAOAI8AAwABBAkAAwAUAJ0AAwABBAkABAAUALEAAwABBAkABQAWAMUAAwABBAkABgAUANsAAwABBAkACgBYAO8AAwABBAkACwAkAUcgZS1kYi1pY29uc1JlZ3VsYXJlLWRiLWljb25zZS1kYi1pY29uc1ZlcnNpb24gMS4wZS1kYi1pY29uc0ZvbnQgZ2VuZXJhdGVkIHVzaW5nIFN5bmNmdXNpb24gTWV0cm8gU3R1ZGlvd3d3LnN5bmNmdXNpb24uY29tACAAZQAtAGQAYgAtAGkAYwBvAG4AcwBSAGUAZwB1AGwAYQByAGUALQBkAGIALQBpAGMAbwBuAHMAZQAtAGQAYgAtAGkAYwBvAG4AcwBWAGUAcgBzAGkAbwBuACAAMQAuADAAZQAtAGQAYgAtAGkAYwBvAG4AcwBGAG8AbgB0ACAAZwBlAG4AZQByAGEAdABlAGQAIAB1AHMAaQBuAGcAIABTAHkAbgBjAGYAdQBzAGkAbwBuACAATQBlAHQAcgBvACAAUwB0AHUAZABpAG8AdwB3AHcALgBzAHkAbgBjAGYAdQBzAGkAbwBuAC4AYwBvAG0AAAAAAgAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAQIBAwEEAQUADG1lc3NhZ2UtbWFpbAtyZWFkLXVucmVhZAZkZWxldGUAAAAAAA==) format('truetype');
        font-weight: normal;
        font-style: normal;
    }
    /* csslint ignore:stop */

    .ddb-icons {
        font-family: 'e-db-icons' !important;
        speak: none;
        font-size: 55px;
        font-style: normal;
        font-weight: normal;
        font-variant: normal;
        text-transform: none;
        line-height: 1;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    .e-message::before {
        content: '\e703';
    }

    .e-edit::before {
        content: '\ea9a';
    }

    .e-delete::before {
        content: '\e705';
    }

    .e-read::before {
        content: '\e704';
    }

    .e-like::before {
        content: '\e81a';
    }

    button {
        margin: 25px 5px 20px 20px;
    }
</style>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace WebApplication1.Controllers
{
    public class DropDownButtonController : Controller
    {
        public IActionResult PopupIcons()
        {
            List<object> items = new List<object>();
            items.Add(new
            {
                text = "Edit",
                iconCss = 'ddb-icons e-edit'
            });
            items.Add(new
            {
                text = "Delete",
                iconCss = 'ddb-icons e-delete'
            });
            items.Add(new
            {
                text = "Mark as Read",
                iconCss = 'ddb-icons e-read'
            });
            items.Add(new
            {
                text = "Like Message",
                iconCss = 'e-icons e-like'
            });
            ViewBag.items = items;
            return View();
        }
    }
}

Actions in DropDownButton can be used to navigate to the other web page when action item is clicked. This can be achieved by Popup items can be customized using the beforeItemRender event. The item render event providing link to the action item using url property.

In the following sample, navigation URL for Flipkart, Amazon, and Snapdeal action items are added using the url property:

razor
navigation.cs
@section ControlsSection{

   @Html.EJS().DropDownButton("navigation").Content("Shop By").Items((IEnumerable<object>)ViewBag.items).IconCss("e-cart-icon e-link").BeforeItemRender("beforeItemRender").Render()

}

<script>

    function beforeItemRender(args) {
        args.element.getElementsByTagName('a')[0].setAttribute('target', '_blank');
    }

</script>

<style>

    /* csslint ignore:start */
    @font-face {
        font-family: 'cart';
        src:
        url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAAKAIAAAwAgT1MvMj0gSQ4AAAEoAAAAVmNtYXDnEOdVAAABiAAAADZnbHlmGatngwAAAcgAAADYaGVhZBKtP4wAAADQAAAANmhoZWEHmQNpAAAArAAAACRobXR4B+j//gAAAYAAAAAIbG9jYQBsAAAAAAHAAA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lZCB1c2luZyBTeW5jZnVzaW9uIE1ldHJvIFN0dWRpb3d3dy5zeW5jZnVzaW9uLmNvbQAgAGMAYQByAHQAUgBlAGcAdQBsAGEAcgBjAGEAcgB0AGMAYQByAHQAVgBlAHIAcwBpAG8AbgAgADEALgAwAGMAYQByAHQARgBvAG4AdAAgAGcAZQBuAGUAcgBhAHQAZQBkACAAdQBzAGkAbgBnACAAUwB5AG4AYwBmAHUAcwBpAG8AbgAgAE0AZQB0AHIAbwAgAFMAdAB1AGQAaQBvAHcAdwB3AC4AcwB5AG4AYwBmAHUAcwBpAG8AbgAuAGMAbwBtAAAAAAIAAAAAAAAACgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgECAQMAEHNob3BwaW5nLWNhcnQtMDUAAAAA) format('truetype');
        font-weight: normal;
        font-style: normal;
    }
    /* csslint ignore:stop */

    .e-cart-icon {
        font-family: 'cart' !important;
        speak: none;
        font-size: 55px;
        font-style: normal;
        font-weight: normal;
        font-variant: normal;
        text-transform: none;
        line-height: 1;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    .e-link::before {
        content: '\e700';
    }

    button {
        margin: 25px 5px 20px 20px;
    }

</style>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace WebApplication1.Controllers
{
    public class DropDownButtonController : Controller
    {
        public IActionResult Navigation()
        {
            List<object> items = new List<object>();
            items.Add(new
            {
                text = 'Flipkart',
                iconCss = 'e-cart-icon e-link',
                url = 'https://www.google.co.in/search?q=flipkart'
            });
            items.Add(new
            {
                text = 'Amazon',
                iconCss = 'e-cart-icon e-link',
                url = 'https://www.google.co.in/search?q=amazon'
            });
            items.Add(new
            {
                text = 'Snapdeal',
                iconCss = 'e-cart-icon e-link',
                url = 'https://www.google.co.in/search?q=snapdeal'
            });
            ViewBag.items = items;
            return View();
        }
    }
}

Template

Item templating

Popup items can be customized using the beforeItemRender event. The item render event triggers while rendering each popup action item. The event argument will be used to identify the action item and customize based on the requirement.

In the following example, the icons in each li items is right aligned by appending span element in li rendering:

razor
itemtemplate.cs
@section ControlsSection{

   @Html.EJS().DropDownButton("item-template").Items((IEnumerable<object>)ViewBag.items).IconCss("e-icons e-align").BeforeItemRender("beforeItemRender").Render()

}

<script>

    function beforeItemRender(args) {
        var alignSpan = createElement('span');
        var text = args.item.text;
        args.element.appendChild(alignSpan);
        alignSpan.setAttribute('class','alignSpan');
        alignSpan.classList.add('e-icons');
        (text === 'Align Left') ? alignSpan.classList.add('e-left') : (text === 'Align Center') ? alignSpan.classList.add('e-center') :
        alignSpan.classList.add('e-right');
    }

</script>

<style>

    .e-align::before {
        content: '\e756';
    }

    .e-left::before {
        content: '\ea9d';
    }

    .e-center::before {
        content: "\e34d";
    }

    .e-right::before {
        content: '\e35e';
    }

    button {
        margin: 25px 5px 20px 20px;
    }

</style>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace WebApplication1.Controllers
{
    public class DropDownButtonController : Controller
    {
        public IActionResult ItemTemplate()
        {
            List<object> items = new List<object>();
            items.Add(new
            {
                text = "Align Left"
            });
            items.Add(new
            {
                text = "Align Center"
            });
            items.Add(new
            {
                text = "Align Right"
            });
            ViewBag.items = items;
        }
    }
}

The whole popup can be customized as per the requirement. In the following example, the popup can be customized by handling it in target property.

razor
popuptemplate.cs
@section ControlsSection{
    <div id="target" style='border: 1px solid black;'>
        <table>
            <caption style='height: 18px; background-color: #e0e0e0;'><b>Insert Table</b></caption>
            <tr class='e-row'>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
            </tr>
            <tr class='e-row'>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
            </tr>
            <tr class='e-row'>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
            </tr>
            <tr class='e-row'>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
            </tr>
            <tr class='e-row'>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
            </tr>
            <tr class='e-row'>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
               <td class='e-data'></td>
            </tr>
        </table>
    </div>

    @Html.EJS().DropDownButton("element").Content("Table").Target("#target").IconCss("e-icons e-table").Render()

}


<style>

.shortcut {
    float: right;
    margin-top: 9px;
    padding-left: 30px;
    height: 100px;
}

.e-data {
  border: 1px solid rgba(0, 0, 0, 0.87);
  padding: 8px;
}

.e-border {
  border: black;
  border-radius: 2px;
  background-color: #fafafa;
}

.e-table::before {
  content: '\e705';
}

.e-row {
  padding-left: 3px;
  padding-right: 3px;
}
        
button {
  margin: 25px 5px 20px 20px;
}

</style>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace WebApplication1.Controllers
{
    public class DropDownButtonController : Controller
    {
        public IActionResult PopupTemplate()
        {
            return View();
        }
    }
}

See Also