This is a migrated thread and some comments may be shown as answers.

Passing Action Data to a Window

3 Answers 1629 Views
Window
This is a migrated thread and some comments may be shown as answers.
Rich Lasker
Top achievements
Rank 1
Rich Lasker asked on 05 Apr 2013, 07:03 PM
I'm following the basic model of displaying a window from an action in a Kendo Grid. The content of the window needs to be loaded via a Partial View from an Action but I cannot figure out how to pass data to the Window so that when it loads the View it can pass that data along. I need to accomplish something akin to the code below.

@(Html.Kendo().Grid<ActivationModel>()
   .Name("activationGrid")
        .Columns(columns =>
   {
            columns.Bound(p => p.RawMessageId).Hidden();
            columns.Command(command => command.Custom("SendActivation").Text("Re-send Activation Email").Click("sendActivation"));
        })
.DataSource(dataSource => dataSource
            .Ajax()
            .ServerOperation(false)
            .PageSize(20)
            .Read(read => read.Action("Activations", "Activation"))
            .Model(model => model.Id(k => k.RawMessageId))
        )
)
    @(Html.Kendo().Window().Name("ActivationWindow")
    .Title("Customer Details")
    .Visible(false)
    .Modal(true)
    .Draggable(true)
    .Width(300)
    .LoadContentFrom("Activation", "ResendActivation", new { rawId = [NEED TO INSERT DATA HERE] })
)

<script type="text/javascript">
    function sendActivation(e) {
        e.preventDefault();
        var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
        var wnd = $("#ActivationWindow").data("kendoWindow");
        wnd.center().open();
    }
</script>

3 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 09 Apr 2013, 03:36 PM
Hello Rich,

I am not sure that I understand the exact question. Basically when using the LoadContentFrom - you should pass your data just as you showed (after all that LoadContentFrom option generates a URL which is used by the $.ajax call on the client / or the iFrame if iFrame is set to true):
e.g.

//view
@(Html.Kendo().Window().Name("name").LoadContentFrom("About", "Home", new { test = "foo"})))
 
//action
        public ActionResult About(string test)
        {
            ViewBag.Message = "Your quintessential app description page.";
 
            return View();
        }

If you are trying to pass additional data when you load the window dynamically on the client side then you need to use the refresh method like explained in the documentation.

http://docs.kendoui.com/api/web/window#methods-refresh


Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Rich Lasker
Top achievements
Rank 1
answered on 09 Apr 2013, 05:02 PM
I'm trying to pass information that is contained in the Grid so in your example:

@(Html.Kendo().Window().Name("name").LoadContentFrom("About",
"Home", new { test = "foo"})))

"foo" would be a value in a cell that would need to be dynamically passed to the LoadContentFrom method.

Essentially you could take the example here:

http://demos.kendoui.com/web/grid/custom-command.html

With the difference being that I want to Load the content from an action instead of a template. I found a solution but it is by using an iframe in the template and constructing the url manually:

<script type="text/x-kendo-template" id="template">
    <div id="activation-container">
        <iframe style="width:380px; height:280px; border-width: 0px;" src="/Activation/ResendActivation?rawId=#= RawMessageId #&amp;userName=#= UserName #" />
    </div>
</script>
0
Petur Subev
Telerik team
answered on 11 Apr 2013, 11:42 AM
Hello Rich,

Thank you for pointing an example. Basically you will need to use the refresh method as I mentioned in my previous post. The difference would be that in the showDetails function you will need to make a similar call to the one:

function showDetails(e) {
                   e.preventDefault();
 
                   var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
                   wnd.refresh({
                                       url: "/yourUrl",
                                     data: { FirstName: dataItem.FirstName}
                   });
                   wnd.center().open();
               }


Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Window
Asked by
Rich Lasker
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Rich Lasker
Top achievements
Rank 1
Share this question
or