How to load a View as Kendo Window popup on Button Click Event

user3470946 picture user3470946 · Apr 1, 2014 · Viewed 15.7k times · Source

I am trying to load a view in a kendo window only on click button’s event. Actually, the popup is displayed each time on the load of the base page. I want that that popup loads only on the click event of the button.

Am I missing something? I've also added onclick event in the html button and called openWindow() javascript method. But it didn't work either, apparently something is wrong.

Is it possible to put the server code of kendo Window below in a jquery function? If yes, how?

<% Html.Kendo().Window()
      .Name("partListGridWindow")
      .Width(800)
.......
%>

Here is my code JQuery:

$(document).ready(function () {
   $("#partListLink")
        .bind("click", function () {
            $("#partListGridWindow").data("kendoWindow").open().center();
        });
});

The kendo Window: In the LoadContentFrom I call PartList which is the Action Name that return my View, from Claim Controller.

<% Html.Kendo().Window()
               .Name("partListGridWindow")
               .Width(800)
               .Modal(true)
               .Title("Part List Info")
               .Content("Loading Part List Info...")
               .LoadContentFrom("PartList", "Claim", Model)
                //.Visible(false)
               .Draggable()
               .Resizable()
               .Render();
%>

Here is the html button:

<a id="partListLink" class="k-button" onclick=openWindow()></a>

By the way, I saw on the Telerik forum they recommend this formula to hide the window with Visible = false but it should be a way to bypass the load of those windows at the beginning of the base page load.

What to do in the case there are tens or more of popup windows to load?

Any help is greatly appreciated! Thank you so much for ur help!

Answer

CSharper picture CSharper · Apr 2, 2014

If your Kendo Window is populating when the base page Loads you have to set .Visible(false). This is how we've done it in our previous project.

This is the click event

function clientLaunchWindow() {

     var window = $("#Window").data("kendoWindow");

     window.refresh({
             url: "/Order/LaunchWindow"        
     });      
     window.center();
     window.open();

Your Controller will just return the partial view

public ActionResult LaunchWindow()
    {
       return PartialView("_PartialView");
    }