Grid Filter

  1. #1

    Grid Filter



    how i can add GridFilters to grid panel Using c# Code



    For Dynamic purpose

    Plz Help me
  2. #2
    Hi,

    Here is how to add them in markup: https://examples1.ext.net/#/GridPane...Filters_Local/

    If you want them added in code behind, you can use the GridFilterCollection, for example:

    <%@ Page Language="C#" %>
    
    <%@ Import Namespace="System.Collections.ObjectModel" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                // the ListFilter for column Size is added in code instead of in markup:
                // <ext:ListFilter DataIndex="Size" Options="extra small,small,medium,large,extra large" />                        
                ListFilter listFilter = new ListFilter();
                listFilter.DataIndex = "Size";
                listFilter.Options = new string[] { "extra small", "small", "medium", "large", "extra large" };
                
                this.GridFilters1.Filters.Add(listFilter);
                
                this.Store1.DataSource = ExtNet1.July2015.FiltersTestData.Data;
                this.Store1.DataBind();
            }
        }
    </script>
    
    <!DOCTYPE>
        
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
         
        <ext:Store runat="server" ID="Store1">
            <Reader>
                <ext:JsonReader IDProperty="Id">
                    <Fields>
                        <ext:RecordField Name="Id" Type="Int" />
                        <ext:RecordField Name="Company" Type="String" />
                        <ext:RecordField Name="Price" Type="Float" />
                        <ext:RecordField Name="Date" Type="Date" DateFormat="yyyy-MM-ddTHH:mm:ss" />
                        <ext:RecordField Name="Size" Type="String" />
                        <ext:RecordField Name="Visible" Type="Boolean" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <SortInfo Field="Company" Direction="ASC" />
        </ext:Store>
        
        <ext:Window 
            ID="Window1" 
            runat="server"         
            Width="700" 
            Height="400" 
            Closable="false"
            Collapsible="true"
            Title="Example" 
            Maximizable="true"
            Layout="Fit">
            <Items>
                <ext:GridPanel runat="server" ID="GridPanel1" Border="false" StoreID="Store1">
                    <ColumnModel runat="server">
                        <Columns>
                            <ext:Column Header="Id" DataIndex="Id" />
                            <ext:Column Header="Company" DataIndex="Company" />
                            <ext:Column Header="Price" DataIndex="Price">
                                <Renderer Format="UsMoney" />
                            </ext:Column>
                            <ext:DateColumn Header="Date" DataIndex="Date" Align="Center" Format="yyyy-MM-dd" />
                            <ext:Column Header="Size" DataIndex="Size" />
                            <ext:Column Header="Visible" DataIndex="Visible" Align="Center">
                                <Renderer Handler="return (value) ? 'Yes':'No';" />
                            </ext:Column>
                        </Columns>
                    </ColumnModel>
                    <LoadMask ShowMask="true" />
                    <Plugins>
                        <ext:GridFilters runat="server" ID="GridFilters1" Local="true">
                            <Filters>
                                <ext:NumericFilter DataIndex="Id" />
                                <ext:StringFilter DataIndex="Company" />
                                <ext:NumericFilter DataIndex="Price" />
                                <ext:DateFilter DataIndex="Date">
                                    <DatePickerOptions runat="server" TodayText="Now" />
                                </ext:DateFilter>                            
                                <ext:BooleanFilter DataIndex="Visible" />
                            </Filters>
                        </ext:GridFilters>
                    </Plugins>                 
                </ext:GridPanel>
            </Items>
        </ext:Window>
    </body>
    </html>
    The above sample demonstrates how to add a ListFilter in code instead of in markup. You can apply the same solution for other filter types, too.

    Hope it helps.
  3. #3
    @Dimitris

    thank you for help

Similar Threads

  1. Replies: 0
    Last Post: May 31, 2013, 8:06 AM
  2. Replies: 13
    Last Post: Feb 28, 2013, 2:06 PM
  3. Replies: 1
    Last Post: Oct 09, 2009, 3:46 AM
  4. Filter Grid from Textfield outside of grid?
    By Tbaseflug in forum 1.x Help
    Replies: 4
    Last Post: May 29, 2009, 5:08 PM
  5. Grid Filter
    By mmiocev in forum 1.x Help
    Replies: 2
    Last Post: Apr 04, 2009, 12:13 PM

Tags for this Thread

Posting Permissions