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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <script type="text/javascript">
            //Put your JavaScript code here.
            var input = null;
            function openSearchWindow() {
                var target = document.activeElement;
                if (target.tagName == "INPUT") {
                    input = target;
                    $find("RadWindow1").show();
                }
            }
            function closeWindow() {
                var searchWindow = $find("RadWindow1");
                var listBox = $telerik.findControl(searchWindow.get_contentElement(), "RadListBox1");
                var value = listBox.get_selectedItem().get_text();
                searchWindow.close();
                input.value = value;
            }
        </script>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        </telerik:RadAjaxManager>
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" CellSpacing="0"
            DataSourceID="SqlDataSource1" GridLines="None" Width="800px" AllowMultiRowEdit="true"
            OnPreRender="RadGrid1_PreRender">
            <MasterTableView DataSourceID="SqlDataSource1" AutoGenerateColumns="False"
                DataKeyNames="OrderID" EditMode="InPlace" CommandItemDisplay="Top">
                <CommandItemTemplate>
                    <asp:Button ID="Button1" runat="server" Text="Search entry"
                        onmousedown="openSearchWindow(); return false;" />
                </CommandItemTemplate>
                <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
                <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                    <HeaderStyle Width="20px"></HeaderStyle>
                </RowIndicatorColumn>
                <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                    <HeaderStyle Width="20px"></HeaderStyle>
                </ExpandCollapseColumn>
                <Columns>
                    <telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32"
                        FilterControlAltText="Filter OrderID column" HeaderText="OrderID"
                        ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
                    </telerik:GridBoundColumn>
                    <telerik:GridDateTimeColumn DataField="OrderDate" DataType="System.DateTime"
                        FilterControlAltText="Filter OrderDate column" HeaderText="OrderDate"
                        SortExpression="OrderDate" UniqueName="OrderDate" ReadOnly="True">
                    </telerik:GridDateTimeColumn>
                    <telerik:GridNumericColumn DataField="Freight" DataType="System.Decimal"
                        FilterControlAltText="Filter Freight column" HeaderText="Freight"
                        SortExpression="Freight" UniqueName="Freight" ReadOnly="True">
                    </telerik:GridNumericColumn>
                    <telerik:GridBoundColumn DataField="ShipName"
                        FilterControlAltText="Filter ShipName column" HeaderText="ShipName"
                        SortExpression="ShipName" UniqueName="ShipName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ShipCountry"
                        FilterControlAltText="Filter ShipCountry column" HeaderText="ShipCountry"
                        SortExpression="ShipCountry" UniqueName="ShipCountry">
                    </telerik:GridBoundColumn>
                </Columns>
                <EditFormSettings>
                    <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                    </EditColumn>
                </EditFormSettings>
            </MasterTableView>
            <FilterMenu EnableImageSprites="False">
            </FilterMenu>
        </telerik:RadGrid>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="SELECT [OrderID], [OrderDate], [Freight], [ShipName], [ShipCountry] FROM [Orders]"></asp:SqlDataSource>
        <telerik:RadWindow ID="RadWindow1" runat="server" Modal="true">
            <ContentTemplate>
                <telerik:RadListBox ID="RadListBox1" runat="server">
                    <HeaderTemplate>
                        <asp:Label ID="Label1" runat="server" Text="Select a value" Font-Bold="true"></asp:Label>
                    </HeaderTemplate>
                    <Items>
                        <telerik:RadListBoxItem Text="One" Selected="true" />
                        <telerik:RadListBoxItem Text="Two" />
                        <telerik:RadListBoxItem Text="Three" />
                    </Items>
                </telerik:RadListBox>
                <br />
                <asp:Button ID="Button2" runat="server" Text="Confirm" OnClientClick="closeWindow(); return false;" />
            </ContentTemplate>
        </telerik:RadWindow>
    </form>
</body>
</html>
