Dynamic Filters not showing...

  1. #1

    Dynamic Filters not showing...


    Hi,
    I'm trying to add filter dynamically. I'm creating the store and the grid columns dynamically..
    Everything works great, except that my filters aren't showing...


    Here is my code behind

    private void AddField(Store store, RecordField field)
            {
                if (Ext.IsAjaxRequest)
                    store.AddField(field);
                else
                    store.Reader.Reader.Fields.Add(field);
            }
            public void LoadGrid(Store store, GridPanel grid,  bool testData)
            {
                try
                { 
                    store.RemoveFields();
    
                    //loop through each column to create the readerfields for the store
                    foreach (FundScreenerReportColumn c in this.Columns)
                        this.AddField(store, new RecordField(c.ColumnName, RecordFieldType.Auto));
    
                    //ADD GRID COLUMNS/FILTERS
                    Column col = null;
                    StringFilter sFilter = null;
                    NumericFilter nFilter = null;
                    ListFilter lFilter = null;
    
                    this.Columns.Sort(new Comparison<FundScreenerReportColumn>(SortByOrder));
                    grid.ColumnModel.Columns.Clear();
                    grid.Plugins.Clear();
                    //create Grid Filter
                    GridFilters f = new GridFilters();
                    grid.Plugins.Add(f); 
                    foreach (FundScreenerReportColumn c in this.Columns)
                    {
                        col = new Column();
                        col.ColumnID = c.ColumnName;
                        col.Header = c.ColumnName;
    
                        col.Sortable = true;
    
                        if (c.DataType.Contains("date"))
                        {
                            col.Renderer.Fn = string.Format("Ext.util.Format.dateRenderer('{0}')", c.DisplayFormat);
                        }
                        if (c.DataType.Contains("float"))
                        {
                            col.Renderer.Fn = string.Format("Ext.util.Format.numberRenderer('{0}')", c.DisplayFormat);
                        }
                        if (c.ColumnName.ToLower().Contains("icon"))
                            col.Renderer.Fn = "getImage";
    
                        col.DataIndex = c.ColumnName;
    
                        grid.ColumnModel.Columns.Add(col); 
                 
    
    
                        //add appropriate filter
                        if (c.FilterGrid.Equals("Numeric"))
                        {
                            nFilter = new NumericFilter();
                            nFilter.DataIndex = c.ColumnName;
                            f.Filters.Add(nFilter);
                        }
                        else if (c.FilterGrid.Equals("List"))
                        {
                            lFilter = new ListFilter();
                            lFilter.DataIndex = c.ColumnName;
                            lFilter.Options = c.FilterGridValues.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                            f.Filters.Add(lFilter);
                        }
                        else
                        {
                            sFilter = new StringFilter();
                            sFilter.SetActive(true);
                            sFilter.AutoDataBind = true;
                            sFilter.DataIndex = c.ColumnName;
                            f.Filters.Add(sFilter);
                        }
                      
    
                    }
    
                   
                    grid.Reconfigure();
                    // DataSet ds = rpt.GetData(false);
    
                    store.DataSource = this.GetData(testData);
                    store.DataBind();
                    //this.GridPanel1.Title = rpt.ReportName;
                    grid.DataBind();
                    if (Ext.IsAjaxRequest)
                        grid.RefreshView();
                }
                catch (Exception er)
                {
                    Utilities.NotificationError(er.ToString());
                }
            }
    Here is the Grid and Store Definitions..


    
        <ext:Store id="Store1" runat="server" autoload="false" AutoDataBind="false">
            <AjaxEventConfig IsUpload="true" />
            <Reader>
             <ext:JsonReader>
             </ext:JsonReader>
            </Reader>
        </ext:Store>
    
    
    <ext:GridPanel id="GridPanel1" striperows="true" AutoDataBind="true" Title="No Report" header="false" trackmouseover="true" runat="server" storeid="Store1" autowidth="true" height="650">
            <SaveMask   ShowMask="true" />
            <LoadMask ShowMask="true" msg="Fetching" />
            <ColumnModel ID="ColumnModel1" runat="server">
                <Columns>
                </Columns>
            </ColumnModel>
            <View>
                <ext:GroupingView ID="GroupingView1" HideGroupedColumn="true" EmptyGroupText="No Groups" EnableGroupingMenu="true" runat="server" ForceFit="true" StartCollapsed="true" GroupTextTpl='{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})' EnableRowBody="true">
                </ext:GroupingView>
            </View>
            <Plugins>
                
            </Plugins>
            <BottomBar>
                <ext:PagingToolbar ID="PagingToolBar1" runat="server" StoreID="Store1" PageSize="50" DisplayInfo="true" DisplayMsg="Displaying Results {0} - {1} of {2}">
                    <Items>
                        <ext:ToolbarButton ID="btnToggleGroups" runat="server" Text="Expand/Collapse Groups" Icon="TableSort" Style="margin-left: 6px;" AutoPostBack="false">
                            <Listeners>
                                <Click Handler="#{GridPanel1}.getView().toggleAllGroups();" />
                            </Listeners>
                        </ext:ToolbarButton>
                    </Items>
                </ext:PagingToolbar>
            </BottomBar>
            <Listeners>     
                    <BeforeUpdate Handler="#{maskDiv}.removeClass('x-hide-display');" />
                    <Update Handler="#{maskDiv}.addClass('x-hide-display');" />  
            </Listeners>
        </ext:GridPanel>
  2. #2

    RE: Dynamic Filters not showing...

    Maybe a little late in the reply, but...

    You need to bind the column with the DataIndex...
    col = new Column();
    col.DataIndex = c.ColumnName;
    col.ColumnID = c.ColumnName;
    col.Header = c.ColumnName;

    Hope this helps.

Similar Threads

  1. [CLOSED] CalendarPanel filters
    By marco.morreale in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Aug 05, 2012, 1:32 PM
  2. Replies: 3
    Last Post: Jan 12, 2012, 3:26 PM
  3. Replies: 23
    Last Post: Nov 04, 2011, 5:19 PM
  4. [CLOSED] Grid Filters Dynamic
    By majunior in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Apr 18, 2011, 3:49 PM
  5. Filters for DataView?
    By shaun in forum 1.x Help
    Replies: 10
    Last Post: Jul 24, 2009, 5:05 PM

Posting Permissions