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

[Solved] Window disappearing issue

3 Answers 126 Views
Window
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Rion
Top achievements
Rank 1
Rion asked on 02 Sep 2010, 04:01 PM
Hello everyone,

I had a thread earlier regarding this issue - however it seems to have vanished. Anyways - as previously mentioned I am having an issue of another vanishing nature. I have a Telerik grid - with links on all of the "username" fields in a specific column - and upon clicking on one of this creates a Telerik Window (which contains a div called "WindowContent" which is used to populate the contents of the Window - depending on the username that it was passed.)

My issue is that the Window is created and works just fine - however upon closing the Window (using the "X" button in the Title bar) I seem to lose access to the window altogether. So if I was to click on another username - the Edit function would attempt to grab the window, but would only find a null.

I have stepped through the javascript several times using Firebug to determine what is happening with the Window, and by watching "$("Window").data("tWindow") I have determined that upon opening the Window the initial time (First click of a username) that the Windows becomes null - so even if I was to attempt to use Client-side events to handle the close method it still would be unable to access the Window.

I am attaching all the code that could relate to this - and any help to solve this issue would be greatly appreciated as I have been battling with it for several days now. (Thank you to nachid - for you help in the previous thread)

Master Page :

<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
<!-- Telerik Style Sheet Registrar -->
    <%= Html.Telerik().StyleSheetRegistrar()
    .DefaultGroup(group => group.Add("telerik.common.css")
                    .Add("telerik.sitefinity.css")) %>  
 
<title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
</head>
<body>
    <div>
        <asp:ContentPlaceHolder ID="MainContent" runat="server">
        </asp:ContentPlaceHolder>
    </div>
    <%= Html.Telerik().ScriptRegistrar() %>
</body>
</html>

Edit Javascript Function :

function Edit(username)
{
    var window = $("Window").data("tWindow");        
    window.center();
    $("#WindowContent").load("Test/Edit", { userName: username });
    window.open();               
}

Window :

<% Html.Telerik().Window()
            .Name("Window")
            .Title("Edit User")
            .Visible(false)
            .Modal(true)
            .Content("<div id=\"WindowContent\" style=\"width: 485px; height: 380px;\"></div>")
            .Width(490)
            .Height(400)
            .Render();      
        %>

Grid : (The Html.JavascriptLink simply creates a link that calls the Javascript function)
           Syntax: ("Link Text", "Function Name", "Parameters[]")


<%= Html.Telerik().Grid<TestingModal.Models.User>()
        .Name("UserGrid")
        .Columns(columns =>
        {
            columns.Bound(o => o.UserName).ClientTemplate(Html.JavascriptLink("<#=UserName#>", "Edit", "<#=UserName#>")).Title("Username").Width(100);
            columns.Bound(o => o.IsActive).Title("Active").ClientTemplate("<input type='checkbox' disabled='disabled' name='Active' <#= IsActive? \"checked='checked'\" : \"\" #> />").Width(40);
        })
        .DataBinding(dataBinding => dataBinding
            .Ajax()
                .Select("_AjaxBinding", "Test")
            )
        .Pageable()
        .Sortable()
%>

Again - Thank you greatly for reading,

Rion

3 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 03 Sep 2010, 10:04 AM
Hello Rion,

The proper selector should be $("#Window").data("tWindow"). The selector that you specified, $('Window') yields no DOM elements, so their .data is null.

That said, is there any reason why you don't use the built-in pop-up editing within the grid? It could save you some trouble with the implementation.

Regards,
Alex Gyoshev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Rion
Top achievements
Rank 1
answered on 03 Sep 2010, 02:48 PM
Hi Alex,

I checked my code and I must have forgotten to include the # in front of the Window - however in it's actual implementation I did include the ("#Window") portion of it. As the Window is able to be viewed on the first click of the "Edit" event - however after the Window is opened it vanishes.

I believe that this is caused by the contents of the Partial View that populates the Window , as it contains a TabStrip. Upon examining the code, and stepping through the Javascript, I found that as soon as the Window is displayed (and the Partial View is rendered) the Window becomes inaccessible. I think that the .Render() that creates the TabStrip inside of the Partial View possibly eliminates the previously rendered Window.

I am including the contents of the Partial View - to possibly help with any attempts to figure out what could be causing this disappearance - if not the TabStrip rendering.

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<TestingModal.Models.User>" %>
 
<%= Html.Telerik().ScriptRegistrar().DefaultGroup(group =>
     {
          group.Add("jquery-1.4.2.min.js");        
          group.Add("telerik.common.min.js");
          group.Add("telerik.tabstrip.min.js");
          group.Add("telerik.list.js");
     })
%>
     
<% Html.Telerik().TabStrip()
           .Name("TabStrip")
           .Items(tabstrip =>
            {
                tabstrip.Add()
                    .Text("Account")
                    .Content(() =>
                        {                            %>
                            //Tab One Content
                       <%});
                tabstrip.Add()
                    .Text("Security")
                    .Content(() =>
                        {%>
                            //Tab Two Content
                       <%});
                tabstrip.Add()
                    .Text("Roles")
                    .Content(() =>
                        {%>
                            //Tab Three Content
                       <%});
            })
            .SelectedIndex(0)
            .Render();
           %>

The reason that I chose this implementation was that I wanted the TabStrip to be used (or some similar functionality) and that I overlooked the Grid on the initial planning of the project and didn't realize the "Pop-Up" editing existed.

I believe that the TabStrip is the culprit - however I could be wrong and it could easily be another issue, Thanks again Alex, and I hope to hear from you regarding this issue :)

-Rion
0
Alex Gyoshev
Telerik team
answered on 03 Sep 2010, 04:04 PM
Hello Rion,

I was unable to reproduce the issue. I created a sample project, based on your posted code -- please take a look at it; I've made some changes (i.e. removed the WindowContent element in favor of the window component public API)

Best wishes,
Alex Gyoshev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Window
Asked by
Rion
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Rion
Top achievements
Rank 1
Share this question
or