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

<%@ 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>
    <style type="text/css">
        .hideFilterOption
        {
            display: none !important;
        }
    </style>

    <script type="text/javascript">
        var oldFilterStyle = "";
        function filterMenuShowing(sender, eventArgs) {
            var menu = eventArgs.get_menu();
            var items = menu.get_items();
            if (eventArgs.get_column().get_dataType() == "System.String") {
                var i = 0;
                while (i < items.get_count()) {
                    if (items.getItem(i).get_value() != "StartsWith" && items.getItem(i).get_value() != "Contains") {
                        var item = items.getItem(i);
                        if (item != null) {
                            if (item.get_element().className != "hideFilterOption") {
                                oldFilterStyle = item.get_element().className;
                            }
                            item.get_element().className = "hideFilterOption";
                        }
                    }
                    else {
                        var item = items.getItem(i);
                        if (item != null) {
                            item.get_element().className = oldFilterStyle;
                        }
                    }
                    i++;
                }
            }
            else if (eventArgs.get_column().get_dataType() == "System.DateTime") {
                var i = 0;
                while (i < items.get_count()) {
                    if (items.getItem(i).get_value() != "EqualTo") {
                        var item = items.getItem(i);
                        if (item != null) {
                            if (item.get_element().className != "hideFilterOption") {
                                oldFilterStyle = item.get_element().className;
                            }
                            item.get_element().className = "hideFilterOption";
                        }
                    }
                    else {
                        var item = items.getItem(i);
                        if (item != null) {
                            item.get_element().className = oldFilterStyle;
                        }
                    }
                    i++;
                }
            }
            else if (eventArgs.get_column().get_dataType() == "System.Decimal") {
                var i = 0;
                while (i < items.get_count()) {
                    if (items.getItem(i).get_value() != "NotEqualTo") {
                        var item = items.getItem(i);
                        if (item != null) {
                            if (item.get_element().className != "hideFilterOption") {
                                oldFilterStyle = item.get_element().className;
                            }
                            item.get_element().className = "hideFilterOption";
                        }
                    }
                    else {
                        var item = items.getItem(i);
                        if (item != null) {
                            item.get_element().className = oldFilterStyle;
                        }
                    }
                    i++;
                }
            }
            else {
                var i = 0;
                while (i < items.get_count()) {
                    var item = items.getItem(i);
                    if (item != null)
                        if (oldFilterStyle != "" && item.get_element().className == "hideFilterOption")
                        item.get_element().className = oldFilterStyle;
                    i++;
                }
            }
        }  
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <telerik:radgrid id="RadGrid1" runat="server" allowfilteringbycolumn="True" allowpaging="True"
        allowsorting="True" datasourceid="SqlDataSource1" gridlines="None" pagesize="10">
        <MasterTableView AutoGenerateColumns="False" DataKeyNames="OrderID" DataSourceID="SqlDataSource1">
            <Columns>
                <telerik:GridEditCommandColumn UniqueName="EditColumn">
                </telerik:GridEditCommandColumn>
                <telerik:GridBoundColumn DataField="OrderID" HeaderText="OrderID" ReadOnly="True"
                    SortExpression="OrderID" UniqueName="OrderID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="OrderDate" DataType="System.DateTime" HeaderText="OrderDate" ReadOnly="True"
                    SortExpression="OrderDate" UniqueName="OrderDate">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Freight" HeaderText="Freight" DataType="System.Decimal" ReadOnly="True"
                    SortExpression="Freight" UniqueName="Freight">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ShipName" HeaderText="ShipName" ReadOnly="True"
                    SortExpression="ShipName" UniqueName="ShipName">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
     
        <ClientSettings>
            <ClientEvents OnFilterMenuShowing="filterMenuShowing" />
        </ClientSettings>
        <FilterMenu EnableTheming="True">
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
        </FilterMenu>
    </telerik:radgrid>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        SelectCommand="SELECT Top(20) [OrderID], [OrderDate], [Freight], [ShipName] FROM [Orders]">
    </asp:SqlDataSource>
    </form>
</body>
</html>
