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

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>
<!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" language="javascript">

            function HideColumn(index) {
                var RadGrid1 = $find("<%=RadGrid1.ClientID %>");
                var columnCount = RadGrid1.get_masterTableView().get_columns().length - 1;
                if (index < 0 || index > columnCount) {
                    alert("Invalid index! The valid range is: " + 0 + "-" + columnCount);
                }
                else {
                    RadGrid1.get_masterTableView().hideColumn(index);
                }
            }

            function ShowColumn(index) {
                var RadGrid1 = $find("<%=RadGrid1.ClientID %>");
                var columnCount = RadGrid1.get_masterTableView().get_columns().length - 1;
                if (index < 0 || index > columnCount) {
                    alert("Invalid index! The valid range is: " + 0 + "-" + columnCount);
                }
                else {
                    RadGrid1.get_masterTableView().showColumn(index);
                }
            }

        </script>

    </telerik:RadScriptBlock>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true" AllowFilteringByColumn="True"
        EnableLinqExpressions="true" AllowSorting="True" GridLines="None" AutoGenerateColumns="False"
        EnableHeaderContextMenu="True" Style="margin-bottom: 0px" OnNeedDataSource="RadGrid1_NeedDataSource"
        Width="600px" ShowGroupPanel="true" Skin="WebBlue" ShowFooter="true" OnItemCreated="RadGrid1_ItemCreated">
        <MasterTableView DataKeyNames="ProductID" HeaderStyle-Width="150px" ShowGroupFooter="false"
            CommandItemDisplay="Top" AllowMultiColumnSorting="true">
            <Columns>
                <telerik:GridClientDeleteColumn UniqueName="GridClientDeleteColumn1">
                    <HeaderStyle Width="30px" />
                </telerik:GridClientDeleteColumn>
                <telerik:GridEditCommandColumn UniqueName="EditColumn">
                    <HeaderStyle Width="30px" />
                </telerik:GridEditCommandColumn>
                <telerik:GridBoundColumn DataField="ProductID" HeaderText="ProductID" UniqueName="ProductID"
                    SortExpression="ProductID" AutoPostBackOnFilter="false" CurrentFilterFunction="EqualTo"
                    ReadOnly="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ProductName" HeaderText="ProductName" UniqueName="ProductName"
                    SortExpression="ProductName" AutoPostBackOnFilter="false" CurrentFilterFunction="Contains">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="UnitPrice" HeaderText="UnitPrice" UniqueName="UnitPrice"
                    SortExpression="UnitPrice" DataType="System.Decimal">
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn UniqueName="LinkButton" HeaderText="Link Button">
                    <ItemTemplate>
                        <asp:HyperLink ID="hlnkButton" runat="server" Text="click" NavigateUrl="~/Default.aspx"></asp:HyperLink>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridCalculatedColumn HeaderText="CalculatedColumn" UniqueName="CalculatedColumn"
                    DataType="System.String" DataFields="ProductName, ProductName, ProductName" Expression='{2} + ",&nbsp;" + (String.IsNullOrEmpty({0}) ? "" : {0}) + ",&nbsp;" + (String.IsNullOrEmpty({1}) ? "" : {1})'>
                </telerik:GridCalculatedColumn>
            </Columns>
        </MasterTableView>
        <ClientSettings AllowDragToGroup="True" AllowColumnsReorder="True" ReorderColumnsOnClient="True"
            ColumnsReorderMethod="Reorder" AllowKeyboardNavigation="true">
            <Scrolling UseStaticHeaders="true" />
            <Resizing AllowColumnResize="true" />
        </ClientSettings>
    </telerik:RadGrid>

    <asp:Button ID="Button3" runat="server" OnClientClick="HideColumn(0); return false;" Text="hide column" />
    <asp:Button ID="Button4" runat="server" OnClientClick="ShowColumn(0); return false;" Text="show column" />
    </form>
</body>
</html>
