<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<TelerikMvcApplication25.Models.Product>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Home Page
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%Html.Telerik().Grid(Model)
                     .Name("Products")
                     .Columns(columns =>
                                  {
                                      columns.Bound(p => p.Id);
                                      columns.Bound(p => p.Name);
                                      columns.Template(p =>
                                                           {%>
                                                                <select onchange="goToAction(this,<%=p.Id %>)">
                                                                    <option value="">--Action--</option>
                                                                    <option value="Order">Add Order</option>
                                                                    <option value="Payment">Add Payment</option>
                                                                </select>
                                                           <%})
                                              .ClientTemplate("<select onchange=\"goToAction(this, <#=Id#>)\">" +
                                                                    "<option value=\"\">--Action--</option>" +
                                                                    "<option value=\"Order\">Add Order</option>" +
                                                                    "<option value=\"Payment\">Add Payment</option>" +
                                                                "</select>");
                                  })
                     .DataBinding(binding => binding.Ajax().Select("Select","Home"))
                     .Pageable()
                     .Render(); 
    %>
    <script type="text/javascript">
        function goToAction(sender, id) {
            var dropDown = $(sender);
            var actionName = dropDown.val();

            if(actionName != "") {                
                window.location.href = $.telerik.formatString('<%=Server.UrlDecode(Url.Action("{0}","Home", new {id = "{1}"}))%>', actionName, id); 
            }
        }
    </script>
</asp:Content>
