Search code examples
jqueryhtmlcsskendo-uikendo-asp.net-mvc

How to center a Kendo Window?


Trying to move the kendo window to center. If I use myModal.center().open(), somehow it moves it a bit lower and right from center. If I use position: { left: "50%", top: "60%" }, it does centers it but just for this particular screen. When I use the same control used at other windows, It is not in center. Any other option to center this freaking window?


Solution

  • I had a resembling issues with Kendo Window. I used Kendo Window Activate event to center the window.

     .Events(eve => eve.Activate("centerKendoWindow"))
    

    Event :

    function centerKendoWindow(e) {
            this.center();
        }
    

    If you are using Kendo Grid inside Kendo Window then you have to make sure that centerKendoWindow() dose not fire before the data is bound to the grid.

    if this is the case then you can use Kendo Grid DataBound event to center the window.

    Grid DataBound Event

     .Events(eve => eve.DataBound("onDataBound"))   
    

    Center Kendo Window

     function onDataBound(args) {
            var grid = $("#kendoaccountgridwindow").data("kendoWindow");
            grid.center();
    }