0

i'm starter in kendo ui, i want use kendoUi window but i have some problem for use i write this code for create window

@(Html.Kendo().Window().Name("Details")
    .Title("Customer Details")
    .Visible(false)
    .Modal(true)
    .Draggable(true)
    .Width(300)       
)

in page i have some button , i want when user click in one of this button set LoadContentFrom dynamically with jquery. But I do not know how to do it. please help me. thanks all.

Pouya
  • 1,908
  • 17
  • 56
  • 78

3 Answers3

5

You need to get hold of the window object, set its url and pass in the query string to the url property. This works for me:

        var window = $("#Details").data("kendoWindow");
        window.refresh({
            url: '/YourController/YourAction/......',

        });
        window.open().center();

Additionally, you can pass in some data to the action as well:

        window.refresh({
            url: '/YourController/YourAction/......',
            data: { id: 10, enterpriseId: 88}

        });

Or you copuld just have a function to create the window on the fly and set it's content url with some parameter:

    function createKendoWindow(contentUrl) {
        $(document.body).append('<div id="Window"></div>');
        $('#Window').kendoWindow({
            title: "Log In",
            modal: true,
            resizable: false,
            width: 400,
            content: contentUrl,
            visible: false,
            minHeight: 350,
            animation: {
                open: {
                    effects: "expandVertical",
                    duration: 1000
                },
            },
            close: function () {
                setTimeout(function () {
                    $('#Window').kendoWindow('destroy');
                }, 200);
            }
        }).html('<img src="761.gif" />').data('kendoWindow').center().open();
    }
Mohammad Sepahvand
  • 17,364
  • 22
  • 81
  • 122
  • This seems a good solution. But I have a problem with loading the content from an MVC PartialView. The view has other Kendo widgets which are not displayed correctly because of JavaScript errors after loading the content. I don't know what's the problem here. – Sven May 06 '16 at 08:53
  • I got it working. I just removed all other windows from my View and only used the createKendoWindow() method. It's working great now. Thanks Mohammad – Sven May 06 '16 at 09:05
2

you can try this:

   $("#yourbuttonID").bind("click", function() {
       $("#Details").data("kendoWindow").open();
   });

to load content to use:

@(Html.Kendo().Window().Name("Details")
    .Title("Customer Details")
    .Visible(false)
    .Modal(true)
    .Draggable(true)
    .LoadContentFrom("brand", "edit") 
    .Width(300)
)
Steven
  • 1,996
  • 3
  • 22
  • 33
COLD TOLD
  • 13,513
  • 3
  • 35
  • 52
  • thanks for asware me. but what 'kendoWindow'? i want load view. – Pouya Jun 24 '13 at 18:40
  • it a refernce ta make sure it window – COLD TOLD Jun 24 '13 at 18:46
  • 1
    if want load view edit from controler brand and send 1 for parameters i write this $("#Details").data("brand/edit/1").open(); but i get error, please help me. thanks – Pouya Jun 24 '13 at 18:49
  • i get this error(i write this code in script tag),0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'LoadContentFrom' – Pouya Jun 24 '13 at 18:54
  • i explain problem, example i have 4 button in form when user click in button edit i want load view edit in window and send param to edit controler, when user click in add button i want load add view and ,... – Pouya Jun 24 '13 at 18:56
  • explain problem, example i have 4 button in form when user click in button edit i want load view edit in window and send param to edit controler, when user click in add button i want load add view and ,... – Pouya Jun 24 '13 at 18:57
0

You can use LoadContentFrom and specify Action and Controller. The action will have its own View attached to it. See here for details.

Kiran
  • 181
  • 3