Position popup open

11 Apr 20222 minutes to read

Popup open position can be changed according to the requirement. Popup open position can be changed in open event by setting top and left for the popup element.

In the following example, the top position of the popup element is changed in open event.

@Html.EJS().DropDownButton("ddbtn").Content("Clipboard").Items((IEnumerable<object>)ViewBag.items).CssClass("e-caret-up")
   .Open("onOpen").Render()

<style>
    button {
        margin: 25% 5px 20px 30%;
    }
</style>
<script>
    function onOpen(args){        
        args.element.parentElement.style.top = ej.base.getInstance(document.getElementById('ddbtn'), ejs.splitbuttons.DropDownButton).element.getBoundingClientRect().top - args.element.parentElement.offsetHeight +'px';
    }
</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();
        }
    }
}