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

[Solved] Two windows in a view

0 Answers 90 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.
Kapil
Top achievements
Rank 1
Kapil asked on 10 Feb 2012, 03:29 PM
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??
Tags
Window
Asked by
Kapil
Top achievements
Rank 1
Share this question
or