<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <telerik:RadCodeBlock runat="server">
        <script type="text/javascript">
            function OnRowCreated(sender, eventArgs) {
                var dataItem = eventArgs.get_gridDataItem();
                for (var i = 1; i < dataItem.get_element().cells.length; i++) {
                    var cell = dataItem.get_element().cells[i];
                    if (cell) {
                        var columnUniqueName = sender.get_masterTableView()._columnsInternal[i].get_uniqueName();
                        cell.uniqeName = columnUniqueName;
                        $addHandler(cell, "click", Function.createDelegate(cell, FilterByCell));
                    }
                }
            }

            function FilterByCell(e) {
                var tableView = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
                tableView.filter(e.target.uniqeName, e.target.innerHTML, "EqualTo");
            }
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadGrid runat="server" AllowFilteringByColumn="true" ID="RadGrid1" AutoGenerateColumns="false">
        <MasterTableView>
            <Columns>
                <telerik:GridBoundColumn HeaderText="ID" DataField="ID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn HeaderText="Item" DataField="Item">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn HeaderText="Date" DataField="Date">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
        <ClientSettings>
            <ClientEvents OnRowCreated="OnRowCreated" />
        </ClientSettings>
    </telerik:RadGrid>
</asp:Content>
