Unable to Open window second time

6 posts, 0 answers
  1. Abdul
    Abdul avatar
    10 posts
    Member since:
    Jun 2014

    Posted 17 Jul 2014 Link to this post

    I'm defining a window in Asp.net mvc with following:
    @(Html.Kendo().Window()
        .Name("staffsec")
        .Title("Edit")
        .Actions(a => a.Minimize().Maximize().Close())
        .Content("")
        .Modal(true)
        .Visible(false)
        .Width(440)
        .Height(500)
        .Scrollable(true)
        .Position(settings =>
        settings.Top(50).Left(300))
    )

    And using follwing Java Script to load the window

     
    var staffId = '@Html.Raw(Json.Encode(Model.StaffModel.StaffId))';
     var windowk = $("#staffsec").data("kendoWindow");
    windowk.refresh({< url: "@Url.Content("/StaffSecurity/Index/")", data: { id: staffId  });<br>windowk.title("Staff Security"); windowk.open();
    return event.preventDefault();

    Issue is, window is displayed only first time i click. Next time i click i get error on console that 'windowk' is undefined. I've used the same technique on different form, there is no issue. 
    Words of wisdom will be appreciated..

    Abdul Rehman







  2. Abdul
    Abdul avatar
    10 posts
    Member since:
    Jun 2014

    Posted 17 Jul 2014 in reply to Abdul Link to this post

    Also, If i'm using the Window without defining (with a div), How to specify its Refresh property to dynamically load a view
    It seems to work here: 
    windowk.refresh({< url: "@Url.Content("/StaffSecurity/Index/")", data: { id: staffId  });
    but does not work with this sort of defination:
     refresh: { url: '@Url.Content("~/StaffSecurity/Index/")', data: { id: staffId } },

    Kindly advise
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 18 Jul 2014 Link to this post

    Hi Abdul,

    Concerning the first question, I suspect that the Window loads a new jQuery instance, which deletes all existing jQuery pluings on the page (including Kendo UI widgets).

    http://docs.telerik.com/kendo-ui/getting-started/web/window/overview#loading-window-content-via-ajax

    http://docs.telerik.com/kendo-ui/getting-started/troubleshooting#javascript-error-that-kendo-widgets-are-unavailable-or-undefined

    Concerning the second question, please do not confuse the refresh method, the refresh event and the content property.

    http://docs.telerik.com/kendo-ui/api/web/window#configuration-content

    Regards,
    Dimo
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  5. Abdul
    Abdul avatar
    10 posts
    Member since:
    Jun 2014

    Posted 19 Jul 2014 in reply to Dimo Link to this post

    Hi Demo! Thank you for your reply..

    Before i walk you thru the issue, let me update you i did some experiments. Page works fine if loaded without Kendo window (a normal page). secondly, if i enable Iframe in winddw decleration .. it runs like a bullet .. no issue 

    Let me give you actual scenario... What is happening is that i'm loading a complete view in Kendo window (using Partial view). The view contains a Kendo grid inside of it..
    Now that's what happens.. When i load it.. it loads the grid without loading the data and prompts error message on console that "Event Handlers are not defined". Those are properly defined and functional and part of grid functionality for AutoSync. If i comment out Event handlers in Kendo decleration. It loads the data but it does not provide the functionality i need.

    I did another experiment that I add Jquery Library/Kendo references in the view. Its only if i add both, It loads the kendo grid without any issue Except that if i click it again, it does not recognize the window object as mentioned in earlier post 

    All apart, works like a charm if i enable iFrame. 

    Can you throw some light?
  6. Abdul
    Abdul avatar
    10 posts
    Member since:
    Jun 2014

    Posted 19 Jul 2014 in reply to Abdul Link to this post

    writing just to make sure I'm not misleading you.. Iframe also only works if i add Jquery and kendo references in the view. 
    I do understand that an additional jquery in the view is doing the damage, but not so sure how to circumvent it as if i don't add references it does not provide kendo grid functionality...
  7. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 22 Jul 2014 Link to this post

    Hello Abdul,

    I am a little confused. It seems there are two separate problems - the duplicate jQuery registration causes the Window to fail, while a possible incorrect event handler implementation causes the event handler to fail. Are you saying that when the Window widget works, the Grid event handler does not work? Are you sure that the event handler functions are defined in a scope, which is available at the time the Grid inside the Window is initialized?

    In case you need further assistance, please provide some simple runnable example, so that I can take a look at it and avoid the guesswork.

    Regards,
    Dimo
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET MVC is VS 2017 Ready