[CLOSED] ListFilter problem

  1. #1

    [CLOSED] ListFilter problem

    Hi,

    I'm implementing a local ListFilter functionality. Please refer to the code below. When I uncheck all the individual Industry checkboxes on the list, the parent Industry filter becomes unchecked, too, as expected. However, it doesn't work the other way around: if I uncheck the parent filter, its individual options selected, if any, remain checked off. Please suggest a workaround.

    Thanks,

    Vadym

    <%@ Page Language="C#" %>
    
    <%@ Register TagPrefix="ext" Namespace="Ext.Net" Assembly="Ext.Net" %>
    <%@ Import Namespace="System.Linq" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    <%@ Import Namespace="Ext.Net" %>
    <script runat="server">
          
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Store1.DataSource = this.Data;
                this.Store1.DataBind();
    
                this.StoreOptions.DataSource = new object[]
                {
                    new object[] { 0, "Basic Materials" },
                    new object[] { 1, "Conglomerates" },
                    new object[] { 2, "Consumer Goods" },
                    new object[] { 3, "Financial" },
                    new object[] { 4, "Healthcare" },
                    new object[] { 5, "Industrial Goods" },
                    new object[] { 6, "Services" },
                    new object[] { 7, "Technology" },
                    new object[] { 8, "Utilities" }
                };
                this.StoreOptions.DataBind();
            }
        }
    
        protected void Store_OnRefreshData(object sender, StoreRefreshDataEventArgs e)
        {
            this.GridPanel1.GetStore().DataSource = this.Data;
        }
    
        private object[] Data
        {
            get
            {
                return new object[]
                {
                    new object[] { "3m Co", "Conglomerates", 71.72, 0.02, 0.03, "9/1 12:00am" },
                    new object[] { "Alcoa Inc", "Basic Materials", 29.01, 0.42, 1.47, "9/1 12:00am" },
                    new object[] { "Altria Group Inc", "Consumer Goods",  83.81, 0.28, 0.34, "9/1 12:00am" },
                    new object[] { "American Express Company", "Financial", 52.55, 0.01, 0.02, "9/1 12:00am" },
                    new object[] { "American International Group, Inc.", "Financial", 64.13, 0.31, 0.49, "9/1 12:00am" },
                    new object[] { "AT&T Inc.", "Technology", 31.61, -0.48, -1.54, "9/1 12:00am" },
                    new object[] { "Boeing Co.", "Industrial", 75.43, 0.53, 0.71, "9/1 12:00am" },
                    new object[] { "Caterpillar Inc.", "Industrial", 67.27, 0.92, 1.39, "9/1 12:00am" },
                    new object[] { "Citigroup, Inc.", "Financial", 49.37, 0.02, 0.04, "9/1 12:00am" },
                    new object[] { "E.I. du Pont de Nemours and Company", "Basic Materials", 40.48, 0.51, 1.28, "9/1 12:00am" },
                    new object[] { "Exxon Mobil Corp", "Energy", 68.1, -0.43, -0.64, "9/1 12:00am" },
                    new object[] { "General Electric Company", "Industrial", 34.14, -0.08, -0.23, "9/1 12:00am" },
                    new object[] { "General Motors Corporation", "Consumer", 30.27, 1.09, 3.74, "9/1 12:00am" },
                    new object[] { "Hewlett-Packard Co.", "Technology", 36.53, -0.03, -0.08, "9/1 12:00am" },
                    new object[] { "Honeywell Intl Inc", "Industrial", 38.77, 0.05, 0.13, "9/1 12:00am" },
                    new object[] { "Intel Corporation", "Technology", 19.88, 0.31, 1.58, "9/1 12:00am" },
                    new object[] { "International Business Machines", "Technology", 81.41, 0.44, 0.54, "9/1 12:00am" },
                    new object[] { "Johnson & Johnson", "Consumer", 64.72, 0.06, 0.09, "9/1 12:00am" },
                    new object[] { "JP Morgan & Chase & Co", "Financial", 45.73, 0.07, 0.15, "9/1 12:00am" },
                    new object[] { "McDonald\"s Corporation", "Consumer", 36.76, 0.86, 2.40, "9/1 12:00am" },
                    new object[] { "Merck & Co., Inc.", "Consumer", 40.96, 0.41, 1.01, "9/1 12:00am" },
                    new object[] { "Microsoft Corporation", "Technology", 25.84, 0.14, 0.54, "9/1 12:00am" },
                    new object[] { "Pfizer Inc", "Consumer", 27.96, 0.4, 1.45, "9/1 12:00am" },
                    new object[] { "The Coca-Cola Company", "Consumer", 45.07, 0.26, 0.58, "9/1 12:00am" },
                    new object[] { "The Home Depot, Inc.", "Consumer", 34.64, 0.35, 1.02, "9/1 12:00am" },
                    new object[] { "The Procter & Gamble Company", "Consumer", 61.91, 0.01, 0.02, "9/1 12:00am" },
                    new object[] { "United Technologies Corporation", "Industrial", 63.26, 0.55, 0.88, "9/1 12:00am" },
                    new object[] { "Verizon Communications", "Communications", 35.57, 0.39, 1.11, "9/1 12:00am" },
                    new object[] { "Wal-Mart Stores, Inc.", "Consumer", 45.45, 0.73, 1.63, "9/1 12:00am" }
                };
            }
        }
          
    </script>
    <!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 id="Head1" runat="server">
        <title>Ext.Net Example</title>
        <script type="text/javascript">
            var template = '<span style="color:{0};">{1}</span>';
    
            var change = function (value) {
                return String.format(template, (value > 0) ? "green" : "red", value);
            };
    
            var pctChange = function (value) {
                return String.format(template, (value > 0) ? "green" : "red", value + "%");
            };
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Store ID="StoreOptions" runat="server">
            <Reader>
                <ext:ArrayReader IDProperty="industry">
                    <Fields>
                        <ext:RecordField Name="sectorID" />
                        <ext:RecordField Name="industry" />
                    </Fields>
                </ext:ArrayReader>
            </Reader>
        </ext:Store>
        <ext:GridPanel ID="GridPanel1" runat="server" StripeRows="true" Title="Companies"
            Region="Center" TrackMouseOver="true" Width="600" Height="300" AutoExpandColumn="company">
            <Store>
                <ext:Store ID="Store1" runat="server" OnRefreshData="Store_OnRefreshData">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="company" />
                                <ext:RecordField Name="industry" />
                                <ext:RecordField Name="price" Type="Float" />
                                <ext:RecordField Name="change" Type="Float" />
                                <ext:RecordField Name="pctChange" Type="Float" />
                                <ext:RecordField Name="lastChange" Type="Date" DateFormat="M/d hh:mmtt" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel ID="ColumnModel1" runat="server">
                <Columns>
                    <ext:Column ColumnID="Company" Header="Company" DataIndex="company" />
                    <ext:Column ColumnID="Industry" Header="Industry" DataIndex="industry" />
                    <ext:Column Header="Price" DataIndex="price">
                        <Renderer Format="UsMoney" />
                    </ext:Column>
                    <ext:Column ColumnID="Change" Header="Change" DataIndex="change">
                        <Renderer Fn="change" />
                    </ext:Column>
                    <ext:Column Header="Change" DataIndex="pctChange">
                        <Renderer Fn="pctChange" />
                    </ext:Column>
                    <ext:DateColumn Header="Last Updated" DataIndex="lastChange" />
                </Columns>
            </ColumnModel>
            <SelectionModel>
                <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" />
            </SelectionModel>
            <BottomBar>
                <ext:PagingToolbar runat="server" StoreID="Store1" PageSize="10" ID="PagingToolbar1">
                    <Items>
                        <ext:ToolbarTextItem ID="ToolbarTextItem1" runat="server" Text="&nbsp;Page size:&nbsp;">
                        </ext:ToolbarTextItem>
                    </Items>
                </ext:PagingToolbar>
            </BottomBar>
            <Plugins>
                <ext:GridFilters runat="server" ID="GridFilters" Local="true">
                    <Filters>
                        <ext:ListFilter DataIndex="industry" StoreID="StoreOptions" LabelField="industry">
                        </ext:ListFilter>
                    </Filters>
                </ext:GridFilters>
            </Plugins>
        </ext:GridPanel>
        </form>
    </body>
    </html>
    Last edited by Daniil; Jun 12, 2012 at 2:11 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Well, it's not a parent checkbox of the option checkboxes. It just indicates the filter is active or not.

    I can suggest the following solution.

    Example
    <ext:ListFilter 
        DataIndex="industry" 
        StoreID="StoreOptions" 
        LabelField="industry">
        <Listeners>
            <Deactivate Handler="this.menu.items.each(function (item) {
                                     item.setChecked(false);
                                 });" />
        </Listeners>
    </ext:ListFilter>
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    Well, it's not a parent checkbox of the option checkboxes. It just indicates the filter is active or not.

    I can suggest the following solution.

    Example
    <ext:ListFilter 
        DataIndex="industry" 
        StoreID="StoreOptions" 
        LabelField="industry">
        <Listeners>
            <Deactivate Handler="this.menu.items.each(function (item) {
                                     item.setChecked(false);
                                 });" />
        </Listeners>
    </ext:ListFilter>
    Thanks much for this solution Daniil! That was exactly what I needed.

    Vadym

Similar Threads

  1. [CLOSED] ListFilter scroll bar?
    By vadym.f in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 05, 2012, 5:53 PM
  2. [CLOSED] ListFilter values
    By cwolcott in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 23, 2012, 3:41 PM
  3. [CLOSED] How to Initialize a ListFilter with Value(s) ?
    By IT1333 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 01, 2011, 8:35 PM
  4. ListFilter with mappings
    By syncos in forum 1.x Help
    Replies: 8
    Last Post: Dec 15, 2010, 1:40 PM
  5. [CLOSED] ListFilter with a StoreID
    By SFritsche in forum 1.x Legacy Premium Help
    Replies: 14
    Last Post: Oct 08, 2010, 1:51 PM

Tags for this Thread

Posting Permissions