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

<%@ 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>
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
        <script type="text/javascript">
            function GetRows() 
            {
                var grid = $find("<%=RadGrid1.ClientID %>");
                var rows = grid.get_masterTableView().get_dataItems();
                
                var rowsId = new Array();
                for (var i = 0; i < rows.length; i++)
                {
                    //rowsId[i] = rows[i].get_id();

                    rowsId[i] = $find(rows[i].get_cell("GridTemplateColumn1").children[0].id).get_parent().get_id();
                }
                alert(rowsId);
            }
        </script>
    </telerik:RadScriptBlock>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True"
        AutoGenerateColumns="False" DataSourceID="SqlDataSource1" GridLines="None" 
        onitemcreated="RadGrid1_ItemCreated" onprerender="RadGrid1_PreRender">
        <MasterTableView DataKeyNames="CustomerID" DataSourceID="SqlDataSource1">
            <Columns>
                <telerik:GridBoundColumn DataField="CustomerID" HeaderText="CustomerID" ReadOnly="True"
                    SortExpression="CustomerID" UniqueName="CustomerID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName"
                    UniqueName="CompanyName">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ContactName" HeaderText="ContactName" SortExpression="ContactName"
                    UniqueName="ContactName">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ContactTitle" HeaderText="ContactTitle" SortExpression="ContactTitle"
                    UniqueName="ContactTitle">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Address" HeaderText="Address" SortExpression="Address"
                    UniqueName="Address">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="City" HeaderText="City" SortExpression="City"
                    UniqueName="City">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="PostalCode" HeaderText="PostalCode" SortExpression="PostalCode"
                    UniqueName="PostalCode">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Country" HeaderText="Country" SortExpression="Country"
                    UniqueName="Country">
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn UniqueName="GridTemplateColumn1" HeaderText="GridTemplateColumn1">
                    <ItemTemplate>
                        <telerik:RadComboBox ID="RadComboBox1" runat="server">
                            <Items>
                                <telerik:RadComboBoxItem Value="FirstValue" Text="FirstText" />
                                <telerik:RadComboBoxItem Value="SecondValue" Text="SecondText" />
                                <telerik:RadComboBoxItem Value="ThirdValue" Text="ThirdText" />
                                <telerik:RadComboBoxItem Value="FourthValue" Text="FourthText" />
                            </Items>
                        </telerik:RadComboBox>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
    <br />
    <asp:Button ID="btnGetRows" runat="server" Text="Client API Get Rows" OnClientClick="GetRows(); return false;" />
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        SelectCommand="SELECT [CustomerID], [CompanyName], [ContactName], [ContactTitle], [Address], [City], [PostalCode], [Country] FROM [Customers]">
    </asp:SqlDataSource>
    </form>
</body>
</html>
