Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > Window > Two windows in a view

Not answered Two windows in a view

Feed from this thread
  • Kapil avatar

    Posted on Feb 10, 2012 (permalink)

    Hello Everyone

    I am trying to accommodate two windows in one view. Both the windows are initially hidden. There are two different buttons in the view that run a javascript that open up the windows. I got one of the windows to work. As for the second window for some odd reason when I am trying to open up the window firebug shows me the error that $("#window").data("tWindow") is undefined (Yes the name of my telerik window is 'window'). If I I don't have the second window as hidden then it renders fine but that is not what I am trying to achieve. I need to have the window to be hidden and then open the window with the click of a button. I am just wondering if you can't have two windows in one view which is kind of hard to believe... Any suggestions?? 

    Here is my view
    @using Abc.Models
    <div>
        @{
            Html.Telerik().Grid<OrderModel>()
                .Name("PreviousYearsOrders")
                .ToolBar(commands => commands.Template(
                 @<text>
                 <input type="button" value="Add new" onclick="NewOrder_onClick()"/>
                 </text>))
                .DataKeys(key => key.Add(o => o.Id))
                .DataBinding(databinding => databinding.Ajax().Select("_AjaxPreviousOrders", "Order")
                                                              .Insert("_InsertOrder", "Order")
                )
                .Columns(c =>
                             {
                                 c.Bound(o => o.Address.SiteName).Title("Site Name");
                                 c.Bound(o => o.Address.Street);
                                 c.Bound(o => o.Address.State);
                                 c.Bound(o => o.Address.City);
                                 c.Bound(o => o.Address.Zip);
                                 c.Bound(o => o.Address.PhoneNumber);
                                 c.Bound(o => o.IC);
                                 c.Bound(o => o.NumberOfOpenTickets);
                             })
                .DetailView(details => details.ClientTemplate(
                               Html.Telerik().Grid<TicketModel>()
                                           .Name("PreviousYearsOrder<#= Id#>")
                                           .DataKeys(key => key.Add(t => t.Id))
                                           .Columns(column =>
                                         {
                                             column.Bound(t => t.Status);
                                          column.Bound(t => t.StatusDate).Title("Status Date");
                                          column.Bound(t => t.OrderDate).Title("Open Date");
                                          column.Bound(t => t.Notes).Title("Order Notes").ClientTemplate("<a href='javascript: onNotesClick(<#= Id#>)' id='NotesLink<#= Id#>'>Notes</a>");
                                          column.Bound(t => t.Product);
                                   })
                                     .DataBinding(databinding => databinding.Ajax().Select("_AjaxTickets", "Ticket", new {orderId = "<#= Id#>"})
                                                  )
                                     .Sortable()
                                     .Filterable()
                                     .ToHtmlString()
                                                                                   ))
                .Sortable()
                .Filterable()
                .Render();                                                     
        }
    </div>
     
    <div>
        @Html.Partial("Notes")    (This is the other window)
    </div>
     
    <div>
        @{
        Html.Telerik().Window()
            .Name("window")
            .Title("Create New Order")
            .Content(@<text></text>)
            .Resizable(resize => resize.Enabled(false))
            .Draggable(true)
            .Modal(true)
            .Width(400)
            .Height(50)
            .Visible(false)
            .Render();
    }
    </div>
     
    @(
        Html.Telerik().ScriptRegistrar()
                            .DefaultGroup(group => group.Add("~/Scripts/Order.js")
                                              .Add("~/Scripts/Notes.js"))
                            )
    )


    UPDATE:

    So what I was suspecting was right. I removed the line that renders the partial view "Notes" and when I click the button to open up the second window it worked fine without any errors.
    @using Abc.Models
    <div>
        @{
            Html.Telerik().Grid<OrderModel>()
                .Name("PreviousYearsOrders")
                .ToolBar(commands => commands.Template(
                 @<text>
                 <input type="button" value="Add new" onclick="NewOrder_onClick()"/>
                 </text>))
                .DataKeys(key => key.Add(o => o.Id))
                .DataBinding(databinding => databinding.Ajax().Select("_AjaxPreviousOrders", "Order")
                                                              .Insert("_InsertOrder", "Order")
                )
                .Columns(c =>
                             {
                                 c.Bound(o => o.Address.SiteName).Title("Site Name");
                                 c.Bound(o => o.Address.Street);
                                 c.Bound(o => o.Address.State);
                                 c.Bound(o => o.Address.City);
                                 c.Bound(o => o.Address.Zip);
                                 c.Bound(o => o.Address.PhoneNumber);
                                 c.Bound(o => o.IC);
                                 c.Bound(o => o.NumberOfOpenTickets);
                             })
                .DetailView(details => details.ClientTemplate(
                               Html.Telerik().Grid<TicketModel>()
                                           .Name("PreviousYearsOrder<#= Id#>")
                                           .DataKeys(key => key.Add(t => t.Id))
                                           .Columns(column =>
                                         {
                                             column.Bound(t => t.Status);
                                          column.Bound(t => t.StatusDate).Title("Status Date");
                                          column.Bound(t => t.OrderDate).Title("Open Date");
                                          column.Bound(t => t.Notes).Title("Order Notes").ClientTemplate("<a href='javascript: onNotesClick(<#= Id#>)' id='NotesLink<#= Id#>'>Notes</a>");
                                          column.Bound(t => t.Product);
                                   })
                                     .DataBinding(databinding => databinding.Ajax().Select("_AjaxTickets", "Ticket", new {orderId = "<#= Id#>"})
                                                  )
                                     .Sortable()
                                     .Filterable()
                                     .ToHtmlString()
                                                                                   ))
                .Sortable()
                .Filterable()
                .Render();                                                    
        }
    </div>
    <div>
        @{
        Html.Telerik().Window()
            .Name("window")
            .Title("Create New Order")
            .Content(@<text></text>)
            .Resizable(resize => resize.Enabled(false))
            .Draggable(true)
            .Modal(true)
            .Width(400)
            .Height(50)
            .Visible(false)
            .Render();
    }
    </div>
      
    @(
        Html.Telerik().ScriptRegistrar()
                            .DefaultGroup(group => group.Add("~/Scripts/Order.js")
                                              .Add("~/Scripts/Notes.js"))
                            )
    )

    Now my question to everyone is that is there anyway I can have both the windows in a view to work??

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > Window > Two windows in a view
Related resources for "Two windows in a view"

ASP.NET MVC Window Features  |  Documentation  |  Demos  |  Telerik TV ]