[CLOSED] GridPanel filter after string is entered

  1. #1

    [CLOSED] GridPanel filter after string is entered

    Hello all,

    In the GridPanel with Remote Filtering example (http://examples2.ext.net/#/GridPanel...ilters_Remote/), I noticed that the string filter is applied as soon as there is a change in the text field. I would like to filter only after entering the complete string, e.g. by activating the checkbox next to "Filters" after completing the filter string.

    Is that possible?
    Last edited by Daniil; Aug 28, 2013 at 4:53 AM. Reason: [CLOSED]
  2. #2
    You may consider a StringFilter override like in the code sample below:

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <%@ Import Namespace="System.Data" %>
    <script runat="server">
        private DataTable TestData
        {
            get
            {
                var updated = new DateTime(2013, 01, 20);
                var addDays = 1;
                var dataTable = new DataTable();
                dataTable.Columns.AddRange(new DataColumn[] { 
                    new DataColumn { ColumnName = "company", DataType = typeof(System.String) },
                    new DataColumn { ColumnName = "industry", DataType = typeof(System.String) },
                    new DataColumn { ColumnName = "price", DataType = typeof(System.Double) },
                    new DataColumn { ColumnName = "change", DataType = typeof(System.Double) },
                    new DataColumn { ColumnName = "pctChange", DataType = typeof(System.Double) },
                    new DataColumn { ColumnName = "lastChange", DataType = typeof(System.DateTime) },
                    new DataColumn { ColumnName = "visible", DataType = typeof(System.Boolean) },
                });
    
                var dataArray = new object[]
                {
                    new object[] { "3m Co", "Conglomerates", 71.72, 0.02, 0.03, updated.AddDays(addDays++), true },
                    new object[] { "Alcoa Inc", "Basic Materials", 29.01, 0.42, 1.47, updated.AddDays(addDays++), true },
                    new object[] { "Altria Group Inc", "Consumer Goods",  83.81, 0.28, 0.34, updated.AddDays(addDays++), true },
                    new object[] { "American Express Company", "Financial", 52.55, 0.01, 0.02, updated.AddDays(addDays++), true },
                    new object[] { "American International Group, Inc.", "Financial", 64.13, 0.31, 0.49, updated.AddDays(addDays++), false },
                    new object[] { "AT&T Inc.", "Technology", 31.61, -0.48, -1.54, updated.AddDays(addDays++), false },
                    new object[] { "Boeing Co.", "Industrial", 75.43, 0.53, 0.71, updated.AddDays(addDays++), false },
                    new object[] { "Caterpillar Inc.", "Industrial", 67.27, 0.92, 1.39, updated.AddDays(addDays++), false },
                    new object[] { "Citigroup, Inc.", "Financial", 49.37, 0.02, 0.04, updated.AddDays(addDays++), false },
                    new object[] { "E.I. du Pont de Nemours and Company", "Basic Materials", 40.48, 0.51, 1.28, updated.AddDays(addDays++), false },
                    new object[] { "Exxon Mobil Corp", "Energy", 68.1, -0.43, -0.64, updated.AddDays(addDays++), true },
                    new object[] { "General Electric Company", "Industrial", 34.14, -0.08, -0.23, updated.AddDays(addDays++), true },
                    new object[] { "General Motors Corporation", "Consumer", 30.27, 1.09, 3.74, updated.AddDays(addDays++), true },
                    new object[] { "Hewlett-Packard Co.", "Technology", 36.53, -0.03, -0.08, updated.AddDays(addDays++), true },
                    new object[] { "Honeywell Intl Inc", "Industrial", 38.77, 0.05, 0.13, updated.AddDays(addDays++), true },
                    new object[] { "Intel Corporation", "Technology", 19.88, 0.31, 1.58, updated.AddDays(addDays++), false },
                    new object[] { "International Business Machines", "Technology", 81.41, 0.44, 0.54, updated.AddDays(addDays++), false },
                    new object[] { "Johnson & Johnson", "Consumer", 64.72, 0.06, 0.09, updated.AddDays(addDays++), false },
                    new object[] { "JP Morgan & Chase & Co", "Financial", 45.73, 0.07, 0.15, updated.AddDays(addDays++), false },
                    new object[] { "McDonald\"s Corporation", "Consumer", 36.76, 0.86, 2.40, updated.AddDays(addDays++), false },
                    new object[] { "Merck & Co., Inc.", "Consumer", 40.96, 0.41, 1.01, updated.AddDays(addDays++), true },
                    new object[] { "Microsoft Corporation", "Technology", 25.84, 0.14, 0.54, updated.AddDays(addDays++), false },
                    new object[] { "Pfizer Inc", "Consumer", 27.96, 0.4, 1.45, updated.AddDays(addDays++), false},
                    new object[] { "The Coca-Cola Company", "Consumer", 45.07, 0.26, 0.58, updated.AddDays(addDays++), true },
                    new object[] { "The Home Depot, Inc.", "Consumer", 34.64, 0.35, 1.02, updated.AddDays(addDays++), true },
                    new object[] { "The Procter & Gamble Company", "Consumer", 61.91, 0.01, 0.02, updated.AddDays(addDays++), true },
                    new object[] { "United Technologies Corporation", "Industrial", 63.26, 0.55, 0.88, updated.AddDays(addDays++), true },
                    new object[] { "Verizon Communications", "Communications", 35.57, 0.39, 1.11, updated.AddDays(addDays++), true },
                    new object[] { "Wal-Mart Stores, Inc.", "Consumer", 45.45, 0.73, 1.63, updated.AddDays(addDays++), true }
                };
    
                foreach (object[] row in dataArray)
                {
                    dataTable.LoadDataRow(row, true);
                }
    
                return dataTable;
            }
        }
    
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Store1.DataSource = this.TestData;
                this.Store1.DataBind();
            }
        }
    </script>
    <!DOCTYPE html>
    <html>
    <head id="Head1" runat="server">
        <title>Local Data Paging - Ext.NET Examples</title>
        <script type="text/javascript">
            if (Ext.ux.grid.filter) {
                Ext.ux.grid.filter.StringFilter.override({
                    init: function (config) {
                        Ext.applyIf(config, {
                            // Set this property to "true" for default behavior
                            // You also have to deactivate the filter manually after clearing the filter input box now
                            enableKeyEvents: false,
                            labelCls: 'ux-rangemenu-icon ' + this.iconCls,
                            hideEmptyLabel: false,
                            labelSeparator: '',
                            labelWidth: 29
                        });
    
                        if (!config.listeners) {
                            config.listeners = {};
                        }
    
                        Ext.applyIf(config.listeners, {
                            scope: this,
                            keyup: this.onInputKeyUp,
                            el: {
                                click: function (e) {
                                    e.stopPropagation();
                                }
                            }
                        });
    
                        this.inputItem = Ext.create('Ext.form.field.Text', config);
                        this.menu.add(this.inputItem);
                        this.menu.showSeparator = false;
                        this.updateTask = Ext.create('Ext.util.DelayedTask', this.fireUpdate, this);
                    }
                });
            }
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Viewport runat="server" Layout="FitLayout">
            <Items>
                <ext:GridPanel ID="GridPanel1" runat="server" Flex="1" SelectionMemory="false">
                    <Store>
                        <ext:Store ID="Store1" runat="server" RemoteSort="false" AutoLoad="true" PageSize="10">
                            <Model>
                                <ext:Model ID="Model1" runat="server" IDProperty="company">
                                    <Fields>
                                        <ext:ModelField Name="company" />
                                        <ext:ModelField Name="industry" />
                                        <ext:ModelField Name="price" Type="Float" />
                                        <ext:ModelField Name="change" Type="Float" />
                                        <ext:ModelField Name="pctChange" Type="Float" />
                                        <ext:ModelField Name="lastChange" Type="Date" />
                                        <ext:ModelField Name="visible" Type="Boolean" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel ID="ColumnModel1" runat="server">
                        <Columns>
                            <ext:Column ID="Column1" runat="server" Text="Company" DataIndex="company" Hideable="true"
                                Width="200">
                                <Editor>
                                    <ext:TextField ID="TextField1" runat="server" />
                                </Editor>
                            </ext:Column>
                            <ext:Column ID="Column2" runat="server" Text="Industry" DataIndex="industry" Hideable="true"
                                Width="200">
                            </ext:Column>
                            <ext:Column ID="Column3" runat="server" Text="Price" Width="75" DataIndex="price"
                                Hideable="false">
                                <Editor>
                                    <ext:TextField ID="TextField2" runat="server" />
                                </Editor>
                            </ext:Column>
                            <ext:Column ID="Column4" runat="server" Text="Change" Width="100" DataIndex="change"
                                Hideable="false" />
                            <ext:Column ID="Column5" runat="server" Text="% Change" Width="100" DataIndex="pctChange"
                                Hideable="true" />
                            <ext:DateColumn ID="DateColumn1" runat="server" Text="Last Updated" Width="120" DataIndex="lastChange"
                                Hideable="true" Hidden="true" Format="MMM dd, yyyy" />
                            <ext:Column ID="Column6" runat="server" Text="Visible" DataIndex="visible" Align="Center"
                                Hideable="true">
                                <Renderer Handler="return (value) ? 'Yes':'No';" />
                            </ext:Column>
                        </Columns>
                    </ColumnModel>
                    <SelectionModel>
                        <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" Mode="Single" />
                    </SelectionModel>
                    <Features>
                        <ext:GridFilters runat="server" Local="true">
                            <Filters>
                                <ext:StringFilter DataIndex="company" EmptyText="Type in description...">
                                </ext:StringFilter>
                            </Filters>
                        </ext:GridFilters>
                    </Features>
                    <BottomBar>
                        <ext:PagingToolbar ID="PagingToolbar1" runat="server">
                            <Items>
                            </Items>
                        </ext:PagingToolbar>
                    </BottomBar>
                    <View>
                        <ext:GridView ID="GridView1" runat="server">
                        </ext:GridView>
                    </View>
                </ext:GridPanel>
            </Items>
        </ext:Viewport>
        </form>
    </body>
    </html>
  3. #3
    Hi Vadym,

    thank you very much. Your solutions works great.

    I am sure this will also help others.

    Thanks again,
    Manni
  4. #4
    You're very welcome Manni :)

    Edit in:

    Location of the original StringFilter definition: premium\trunk\Ext.Net\Build\Ext.Net\ux\grid\gridfi lters\gridfilters-debug.js or gridfilters.js
    Last edited by vadym.f; Aug 27, 2013 at 9:14 PM.

Similar Threads

  1. Replies: 7
    Last Post: Mar 12, 2013, 9:15 AM
  2. Grid string filter arrow navigation
    By ambruslaco in forum 1.x Help
    Replies: 0
    Last Post: Feb 26, 2013, 1:45 PM
  3. Replies: 2
    Last Post: May 01, 2012, 5:57 PM
  4. Get filter string for Remote Filtering
    By peter.campbell in forum 1.x Help
    Replies: 2
    Last Post: Feb 15, 2011, 4:34 PM
  5. Replies: 2
    Last Post: Aug 31, 2009, 7:03 PM

Tags for this Thread

Posting Permissions