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.

<ejs-dropdownbutton id="ddbtn" items="ViewBag.items" cssClass="e-caret-up" content="Clipboard" open="onOpen"></ejs-dropdownbutton>

<style>
    button {
        margin: 10%;
    }
</style>
<script>
    function onOpen(args){
        args.element.parentElement.style.top = document.getElementById('ddbtn').ej2_instances[0].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();
        }
    }
}