[CLOSED] Filter blank records

Page 2 of 2 FirstFirst 12
  1. #11
    Hi,

    Thanks for the solution but I'm using combobox in grid editor and selected value in combobox is showing " " when edits the row.

    Please give an temporary solution to resolve this.

    Thanks,
    Vamsi.
  2. #12
    I see the quick fix causes more trouble than it solves.

    We are working on a proper solution right now and we will update this thread soon.

    Sorry for any inconvenience caused.
  3. #13
    @Vamsi, with your initial test case from the post #3 please try to add this script on the page.
    <script>
        Ext.grid.filters.filter.List.override({
            enableEmptyOption: true,
            emptyValue: "nullUndefinedEmptyString",
            emptyText: "[Empty]",
    
            getOptionsFromStore: function (store) {
                var me = this,
                    options = me.callParent(arguments),
                    dataIndex = me.dataIndex,
                    labelIndex = me.labelIndex,
                    indexesToRemove = [],
                    i, len;
    
                if (me.enableEmptyOption) {
                    // Clean up the options first
                    Ext.Array.each(options, function(option, index) {
                        if (Ext.isEmpty(option[0])) {
                            indexesToRemove.push(index);
                        }
                    });
    
                    for (i = indexesToRemove.length - 1; i > -1; i--) {
                        Ext.Array.removeAt(options, indexesToRemove[i]);
                    }
    
                    Ext.Array.insert(options, 0, [ [me.emptyValue, me.emptyText] ]);
                }
                    
                return options;
            },
    
            getFilterConfig: function (config, key) {
                var listFilter = this,
                    config = listFilter.callParent(arguments);
            
                if (listFilter.enableEmptyOption) {
                    delete config.operator;
    
                    config.getFilterFn = function() {
                        return function (candidate) {
                            var v = this._filterValue;
    
                            if (Ext.Array.contains(v, listFilter.emptyValue)) {
                                v.push(null, undefined, "");
                                Ext.Array.remove(v, listFilter.emptyValue);
                            }
    
                            return Ext.Array.contains(v, this.getCandidateValue(candidate, v));
                        }
                    }
                }
    
                return config;
            }
        });
    </script>
  4. #14
    For completeness, I post the following sample, which works fine for me. Choose whichever suits you but out of curiosity, does it work for you?

    <%@ Page Language="C#" %>
    
    <%@ Import Namespace="System.Collections.Generic" %>
    
    <script runat="server">
        
        private object Data
        {
            get
            {
                string now = DateTime.Now.ToLongTimeString();
    
                return new List<object>
                {
                    new {StringField = "Set1_1", IntField = 1, Timestamp = now},
                    new {StringField = "", IntField = 2, Timestamp = now},
                    new {StringField = "Set1_2", IntField = 3, Timestamp = now},
                    new {StringField = "", IntField = 4, Timestamp = now},
                    new {StringField = "", IntField = 5, Timestamp = now},
                    new {StringField = "Set1_3", IntField =5, Timestamp = now}                
                };
            }    
        }
        
        private void BindData()
        {
            this.Store1.DataSource = this.Data;
            this.Store1.DataBind();
        }
    
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.BindData();
            }
        }
    </script>
    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        <script>
            var onLoad = function (combo, recs) {
                var data = App.Store1.collect("StringField");
    
                var data2 = [];
                for (var i = 0; i < data.length; i++)
                {
                    data2.push({});
                    data2[i]["StringField"] = data[i];
                }
                console.log(data2);
                App.Store2.loadData(data2);
            };
        </script>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <h1>
            Grid and Store Reconfigure</h1>
    
            <ext:Store 
                runat="server"
                ID="Store2">
                <Model>
                    <ext:Model runat="server">
                        <Fields>
                            <ext:ModelField Name="StringField" Type="String">
                            </ext:ModelField>
                        </Fields>
                    </ext:Model>
                </Model>
                <Reader>
                    <ext:ArrayReader />
                </Reader>
            </ext:Store>
    
            <ext:GridPanel ID="GridPanel1" runat="server" Title="Grid" Width="600" Height="350">
            <Store>
                <ext:Store ID="Store1" runat="server" IgnoreExtraFields="false">
                    <Model>
                        <ext:Model runat="server">
                            <Fields>
                                <ext:ModelField Name="StringField" Type="String">
                                    <Convert Fn="function(v) { return (v.length <= 0) ? '&nbsp;' : v; }" />
                                </ext:ModelField>
                                <ext:ModelField Name="IntField" Type="Int" />
                                <ext:ModelField Name="Timestamp" Type="Date" />
                            </Fields>
                        </ext:Model>
                    </Model>
                    <Listeners>
                        <Load Fn="onLoad" />
                    </Listeners>
                </ext:Store>            
            </Store>
            <ColumnModel>
                <Columns>
                    <ext:Column runat="server" DataIndex="StringField" Text="String">                    
                        <Filter>
                            <ext:ListFilter />
                        </Filter>
                        <Editor>
                            <ext:ComboBox
                                runat="server" 
                                StoreID="Store2" 
                                QueryMode="Local"
                                TriggerAction="All"
                                DataIndex="StringField"
                                DisplayField="StringField" 
                                ValueField="StringField">
                            </ext:ComboBox>
                        </Editor>
                    </ext:Column>
                    <ext:Column runat="server" DataIndex="IntField" Text="Int" />
                    <ext:Column runat="server" DataIndex="Timestamp" Text="Timestamp"/>
                </Columns>
            </ColumnModel>
            <SelectionModel>
                <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" Mode="Single" />
            </SelectionModel>
            <Plugins>
                <ext:GridFilters />
                <ext:CellEditing />
            </Plugins>
        </ext:GridPanel>
    </body>
    </html>
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Filter records between 2 dates Gridpanel
    By aldoblack in forum 3.x Help
    Replies: 2
    Last Post: May 13, 2015, 12:06 PM
  2. Replies: 5
    Last Post: Feb 24, 2015, 5:01 AM
  3. Replies: 5
    Last Post: Jun 14, 2011, 11:47 AM
  4. [CLOSED] "Blank" gridpanel column until edited...then blank again!
    By dmoore in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jan 24, 2011, 4:11 PM
  5. Replies: 3
    Last Post: Jun 29, 2010, 2:54 PM

Tags for this Thread

Posting Permissions