Search results

Open a dialog on popup item click

This section explains about how to open a dialog on DropdownButton popup item click. This can be achieved by handling dialog open in select event of the DropdownButton.

In the following example, Dialog will open while selecting Other Folder... item.

razor
dialogSample-mvc.cs
dialogButton-core.cs
<div>
   @Html.EJS().Dialog("dialog").Header("Move Items").Content("Move Items To 'Web Team'").Width("250px").Visible(false).Position(obj => obj.X("100").Y("100")).Buttons(ViewBag.button).Render()

   @Html.EJS().DropDownButton("ddbtn").Content("Move").Items((IEnumerable<object>)ViewBag.items).CssClass("e-vertical").IconCss("ddb-icons e-folder").IconPosition(Syncfusion.EJ2.SplitButtons.SplitButtonIconPosition.Top).Select("onSelect").Render()
</div>


<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///AAAAAQAEAAAAAQACAAMAAAAAAAAAHAA6AFwAAAACAAAAAAPqA2UABgAKAAA3IREjCQEj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AZkZWxldGUAAAAAAA==) 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-folder::before {
        content: '\e703';
    }

    button {
      margin: 25px 5px 20px 20px;
    }
</style>

<script>
    function onSelect(args){
        if (args.item.text === 'Other Folder...') {
            ej.base.getInstance(document.getElementById('dialog'), ejs.popups.Dialog).show();
        }
    }
    function btnClick () {
        ej.base.getInstance(document.getElementById('dialog'), ejs.popups.Dialog).hide();
    }
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Syncfusion.EJ2.Buttons;
using Syncfusion.EJ2.Popups;
namespace EJ2CoreSampleBrowser.Controllers.Button
{
    public partial class ButtonController : Controller
    {
        public class ButtonModel
        {
            public string content { get; set; }
            public string cssClass { get; set; }
            public bool isPrimary { get; set; }
            public string Click { get; set; }

        }

        public ActionResult DropDownButton()
        {

            List<object> items = new List<object>();
            items.Add(new
            {
                text = "Archive"
            });
            items.Add(new
            {
                text = "Inbox"
            });
            items.Add(new
            {
                text = "HR Portal"
            });
            items.Add(new
            {
                separator = true
            });
            items.Add(new
            {
                text = "Other Folder..."
            });
            items.Add(new
            {
                text = "Copy to Folder"
            });
            ViewBag.button = new
            {
                content="OK", cssClass="e-flat", isPrimary = true
            };
            ViewBag.items = items;
            List<DialogDialogButton> buttons = new List<DialogDialogButton>() { };
            buttons.Add(new DialogDialogButton() { Click = "btnClick", ButtonModel = new ButtonModel() { content = "OK", isPrimary = true, cssClass = "e-flat" } });
            ViewBag.button = buttons;
            return View();
        }
    }
}
public ActionResult DialogButton()
{
    ViewBag.DialogButtons = new  {
        isPrimary = true,
        cssClass = "e-flat",
        content = "Submit",
        click = "dlgButtonClick"
    };
    return View();
}