how to populate a KendUI Window

2019-09-07 13:48发布

问题:

I am new to Kendo UI. I would like to be able to display a popup with the results from my controller.

My example is very simple. I have this data on my page.

Some text    [Create]

When I click on [Create], a call in made to my controller. The controller will create a PDF file. Next, I would like to be able to display the pdf in a KendoUI Window.

I am getting hung up on how to pass info back to page so the KendoUi Window is aware of the PDF file name to display.

Thanks in advance for your tips.

Steve

MVC 4

KendoUI 2012.2.270

回答1:

There are two basic approaches:

  1. You create the window when page is loaded and have a function for changing the content and make it visible.
  2. You create the window each time.

Assuming that you for 1. Then you have an HTML that is something like this

<div id="popup_window">
</div>
<a href="#" id="show">Create PDF</a>

Then you define the window and the click bind for triggering the open as:

$("#popup_window").kendoWindow({
    title    :"PDF document",
    visible  :false
});

$("#show").click(function () {
    $("#popup_window").html("<object id='pdf' data='doc.pdf' type='application/pdf'/>");
    $("#popup_window").data("kendoWindow").open();
});

Where I create a kendoWindow but set it's visibility to not visible. Then I bind a function to the click on the Create PDF message that sets the content to an HTML object where data attribute is the pdf document and then open by invoking kendoWindow open method.