<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server" />
    <div>
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true" AllowSorting="true"
            AutoGenerateColumns="false" PageSize="50" AllowMultiRowSelection="true" Width="100%">
            <ItemStyle Font-Size="8pt" Height="10px" />
            <AlternatingItemStyle Font-Size="8pt" Height="10px" />
            <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" />
            <ClientSettings>
                <Scrolling AllowScroll="true" ScrollHeight="100%" UseStaticHeaders="true" />
                <DataBinding Location="Default.aspx" SelectMethod="GetDataAndCount" />
                <ClientEvents OnCommand="RadGridCommand" OnDataBound="DataBound" />
                <Selecting AllowRowSelect="true" />
            </ClientSettings>
            <MasterTableView TableLayout="Fixed">
                <CommandItemTemplate>
                    <div style="height: 30px; text-align: right;">
                        <asp:Button ID="imgCancelChanges" runat="server" Text="Cancel" ToolTip="Cancel changes"
                            Height="24px" Style="cursor: pointer; margin: 2px 5px 0px 0px;" OnClientClick="CancelChanges(); return false;" />
                        <asp:Button ID="imgProcessChanges" runat="server" Text="Save" ToolTip="Save changes"
                            Height="24px" Style="cursor: pointer; margin: 2px 5px 0px 0px;" OnClientClick="ProcessChanges(); return false;" />
                        <asp:Button ID="btnEditMarkup" runat="server" Text="Edit Selected Rows" Height="24px"
                            Style="cursor: pointer; margin: 2px 5px 0px 0px;" OnClientClick="OpenWindow(); return false;" />
                    </div>
                </CommandItemTemplate>
                <Columns>
                    <telerik:GridBoundColumn UniqueName="NewId" DataField="NewId" HeaderText="Product #"
                        ReadOnly="True" HeaderStyle-Width="80px" />
                    <telerik:GridBoundColumn UniqueName="FirstName" DataField="FirstName" HeaderText="Product Name"
                        ReadOnly="True" HeaderStyle-Width="200px" />
                    <telerik:GridBoundColumn UniqueName="LastName" DataField="LastName" HeaderText="Mfg #"
                        ReadOnly="True" HeaderStyle-Width="85px" />
                    <telerik:GridButtonColumn ButtonType="LinkButton" Text="Select" HeaderText="Select"
                        CommandName="Select" HeaderStyle-Width="75px">
                    </telerik:GridButtonColumn>
                    <telerik:GridClientDeleteColumn Text="Delete" HeaderText="Delete" CommandName="Delete"
                        HeaderStyle-Width="60px">
                    </telerik:GridClientDeleteColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
        <telerik:RadScriptBlock runat="server" ID="RadScriptBlock1">
            <script type="text/javascript">
                function RadGridCommand(sender, args) {
                    if (args.get_commandName() == "Delete") {
                        args.set_cancel(true);
                        //item index
                        var itemIndex = args.get_commandArgument();
                    }
                    if (args.get_commandName() == "Select") {
                        args.set_cancel(true);
                        sender.get_masterTableView().selectItem(args.get_commandArgument());
                    }
                }

                function DataBound(sender, args) {

                    var grid = $find("<%= RadGrid1.ClientID %>")
                    grid.repaint();
                }
            </script>
        </telerik:RadScriptBlock>
    </div>
    </form>
</body>
</html>
