[OPEN] [#325] Filters not clearing

  1. #1

    [OPEN] [#325] Filters not clearing

    Hi,

    I have a SelectBox with a default filter applied to hide the data until I can apply the real filter values and filter the data..
                     <ext:SelectBox runat="server" ID="SelectCarrier" FieldLabel="Carrier" AllowBlank="False"
                                                           ValueField="Id" DisplayField="Name" Flex="1" Name="CarrierId">
                                                <Store>
                                                    <ext:Store runat="server" Data="<%# Model.Carriers %>" AutoDataBind="True" RemoteFilter="False">
                                                        <Filters>
                                                            <ext:DataFilter Property="GroupId" Value="-1" />
                                                        </Filters>
                                                        <Model>
                                                            <ext:Model runat="server" IDProperty="Id">
                                                                <Fields>
                                                                    <ext:ModelField Name="Id" Type="Int" />
                                                                    <ext:ModelField Name="UnitId" Type="Int" />
                                                                    <ext:ModelField Name="GroupId" Type="Int" />
                                                                    <ext:ModelField Name="HasCostMatrix" Type="Boolean" />
                                                                    <ext:ModelField Name="Name" Type="String" />
                                                                </Fields>
                                                            </ext:Model>
                                                        </Model>
                                                    </ext:Store>
                                                </Store>
    This worked fine in 2.1 but when I call clearFilter() it doesn't seem to remove the original filter specified in the markup.

    e.g.

    App.SelectCarrier.store.clearFilter()
    And the data is still filtered even though the App.SelectCarrier.store.filters.length is zero...

    Thanks,
    Last edited by Daniil; Aug 16, 2013 at 3:33 AM. Reason: [OPEN] [#325]
  2. #2
    Hello!

    Try to reload the store:

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            Store store = this.SelectBox1.GetStore();
            
            store.DataSource = new object[]
            {
                new object[] { "AL", "Alabama", "The Heart of Dixie" },
                new object[] { "AK", "Alaska", "The Land of the Midnight Sun" },
                new object[] { "AZ", "Arizona", "The Grand Canyon State" },
                new object[] { "AR", "Arkansas", "The Natural State" },
                new object[] { "CA", "California", "The Golden State" },
                new object[] { "CO", "Colorado", "The Mountain State" },
                new object[] { "CT", "Connecticut", "The Constitution State" },
                new object[] { "DE", "Delaware", "The First State" },
                new object[] { "DC", "District of Columbia", "The Nation's Capital" },
                new object[] { "FL", "Florida", "The Sunshine State" },
                new object[] { "GA", "Georgia", "The Peach State" },
                new object[] { "HI", "Hawaii", "The Aloha State" },
                new object[] { "ID", "Idaho", "Famous Potatoes" },
                new object[] { "IL", "Illinois", "The Prairie State" },
                new object[] { "IN", "Indiana", "The Hospitality State" },
                new object[] { "IA", "Iowa", "The Corn State" },
                new object[] { "KS", "Kansas", "The Sunflower State" },
                new object[] { "KY", "Kentucky", "The Bluegrass State" },
                new object[] { "LA", "Louisiana", "The Bayou State" },
                new object[] { "ME", "Maine", "The Pine Tree State" },
                new object[] { "MD", "Maryland", "Chesapeake State" },
                new object[] { "MA", "Massachusetts", "The Spirit of America" },
                new object[] { "MI", "Michigan", "Great Lakes State" },
                new object[] { "MN", "Minnesota", "North Star State" },
                new object[] { "MS", "Mississippi", "Magnolia State" },
                new object[] { "MO", "Missouri", "Show Me State" },
                new object[] { "MT", "Montana", "Big Sky Country" },
                new object[] { "NE", "Nebraska", "Beef State" },
                new object[] { "NV", "Nevada", "Silver State" },
                new object[] { "NH", "New Hampshire", "Granite State" },
                new object[] { "NJ", "New Jersey", "Garden State" },
                new object[] { "NM", "New Mexico", "Land of Enchantment" },
                new object[] { "NY", "New York", "Empire State" },
                new object[] { "NC", "North Carolina", "First in Freedom" },
                new object[] { "ND", "North Dakota", "Peace Garden State" },
                new object[] { "OH", "Ohio", "The Heart of it All" },
                new object[] { "OK", "Oklahoma", "Oklahoma is OK" },
                new object[] { "OR", "Oregon", "Pacific Wonderland" },
                new object[] { "PA", "Pennsylvania", "Keystone State" },
                new object[] { "RI", "Rhode Island", "Ocean State" },
                new object[] { "SC", "South Carolina", "Nothing Could be Finer" },
                new object[] { "SD", "South Dakota", "Great Faces, Great Places" },
                new object[] { "TN", "Tennessee", "Volunteer State" },
                new object[] { "TX", "Texas", "Lone Star State" },
                new object[] { "UT", "Utah", "Salt Lake State" },
                new object[] { "VT", "Vermont", "Green Mountain State" },
                new object[] { "VA", "Virginia", "Mother of States" },
                new object[] { "WA", "Washington", "Green Tree State" },
                new object[] { "WV", "West Virginia", "Mountain State" },
                new object[] { "WI", "Wisconsin", "America's Dairyland" },
                new object[] { "WY", "Wyoming", "Like No Place on Earth"} 
            };
            
            store.DataBind();
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>SelectBox - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" />
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <h3>SelectBox</h3>
            
            <p>A Component similar to an HTML SELECT input. Supports clicking and dragging
            through the list, with item selection occurring when the mouse button is released.</p>
            
            <ext:SelectBox
                ID="SelectBox1"
                runat="server" 
                DisplayField="state"
                ValueField="abbr"
                EmptyText="Select a state...">
                <Store>
                    <ext:Store runat="server">
                        <Filters>
                            <ext:DataFilter Property="state" Value="Montana" />
                        </Filters>
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="abbr" />
                                    <ext:ModelField Name="state" />
                                    <ext:ModelField Name="nick" />
                                </Fields>
                            </ext:Model>
                        </Model>            
                    </ext:Store>    
                </Store>    
            </ext:SelectBox>
            
            <ext:Button runat="server" Text="Clear Filters" Handler="
                App.SelectBox1.getStore().clearFilter();
                App.SelectBox1.getStore().reload();
                "></ext:Button>
        </form>
    </body>
    </html>
  3. #3
    Hi everybody,

    I see the issue and would consider a bug. Though, I am not 100% sure Sencha will agree, but probably. Anyway, reported.
    http://www.sencha.com/forum/showthread.php?270003

    For now, reloading the data to the Store looks an appropriate solution. However, a Store's reload call makes a request to the page. It is possible to avoid it using a loadData method instead. Also a clearFilter call removes an internal SelectBox's queryFilter which is good to return back. One moment more, I think it is good to remove a SelectBox's lastQuery.

    Putting it all together I can suggest the following script.
    <ext:Button 
        runat="server" 
        Text="Clear Filters"
        Handler="var store = App.SelectBox1.getStore();
                 store.clearFilter();
                 store.addFilter(App.SelectBox1.queryFilter, false);
                 store.loadData(store.proxy.data);
                 delete App.SelectBox1.lastQuery;" />
  4. #4
    Sencha has open a bug.

    We have created an issue to track this defect: https://github.com/extnet/Ext.NET/issues/325
  5. #5
    OK thanks.

Similar Threads

  1. [CLOSED] Clearing the CheckboxSelectionModel
    By prost in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Mar 14, 2013, 12:49 PM
  2. [CLOSED] Best practice clearing filters when Stateful="true"
    By CarWise in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 24, 2012, 2:23 PM
  3. Replies: 3
    Last Post: Jan 12, 2012, 3:26 PM
  4. Combo is not clearing
    By Nagaraju in forum 1.x Help
    Replies: 3
    Last Post: May 20, 2011, 10:27 AM
  5. Clearing out a GridPanel
    By principal_X in forum 1.x Help
    Replies: 0
    Last Post: Feb 05, 2009, 7:32 PM

Posting Permissions