[CLOSED] How to Initialize a ListFilter with Value(s) ?

  1. #1

    [CLOSED] How to Initialize a ListFilter with Value(s) ?

    <ext:ListFilter DataIndex="something" StoreID="Store1" LabelField="DisplayName" Value="10" />
    I know that in the above case the value (integer) that I want to initialize is 10.
    How can I set that as the default filter value on a ListFilter?
    Last edited by Daniil; Jun 02, 2011 at 7:15 AM. Reason: [CLOSED]
  2. #2
    Hi,

    ListerFilter doesn't support int options.

    In general, I would suggest you to use NumericFilter.

    But if you need ListFilter for an int column, I can demonstrate you the following example: see ValidateRecord and note that I populate StoreOptions with the string options.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { 1, "test1" },
                    new object[] { 2, "test2" },
                    new object[] { 3, "test3" }
                };
                store.DataBind();
    
                this.StoreOptions.DataSource = new object[] 
                { 
                    new object[] { "1" },
                    new object[] { "2" },
                    new object[] { "3" }
                };
                this.StoreOptions.DataBind();
            }
        }
    </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 runat="server">
        <title>Ext.Net Example</title>
    
        <script type="text/javascript">
            var myValidateRecord = function (record) {
                return this.getValue().indexOf(record.get(this.dataIndex) + '') > -1;
            }
        </script>
    
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:Store ID="StoreOptions" runat="server">
            <Reader>
                <ext:ArrayReader IDProperty="test1">
                    <Fields>
                        <ext:RecordField Name="test1" />
                    </Fields>
                </ext:ArrayReader>
            </Reader>
        </ext:Store>
        <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
            <Store>
                <ext:Store runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="test1" />
                                <ext:RecordField Name="test2" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column Header="Test1" DataIndex="test1" />
                    <ext:Column Header="Test2" DataIndex="test2" />
                </Columns>
            </ColumnModel>
            <Plugins>
                <ext:GridFilters ID="GridFilters1" runat="server" Local="true">
                    <Filters>
                        <ext:ListFilter 
                            DataIndex="test1" 
                            StoreID="StoreOptions"
                            LabelField="test1"
                            Value="3">
                            <ValidateRecord Fn="myValidateRecord" />
                        </ext:ListFilter>
                    </Filters>
                </ext:GridFilters>
            </Plugins>
        </ext:GridPanel>
        </form>
    </body>
    </html>
  3. #3

    Thanks

    Tanks Daniil.

    I converted the fields to string for both stores (listfilter store and the grid store).
    Now it works with just Value="10".

    Please mark as solved.

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 problem
    By vadym.f in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 12, 2012, 12:51 PM
  3. [CLOSED] ListFilter values
    By cwolcott in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 23, 2012, 3:41 PM
  4. [CLOSED] ListFilter with a StoreID
    By SFritsche in forum 1.x Legacy Premium Help
    Replies: 14
    Last Post: Oct 08, 2010, 1:51 PM
  5. Replies: 9
    Last Post: Feb 24, 2009, 3:17 PM

Tags for this Thread

Posting Permissions