[CLOSED] Filter blank records

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Filter blank records

    Hi,

    I'm using listfilter plugin to filter the records in gridpanel.

    In my gridpanel I have empty records so how we can filter only empty/blank records.

    Please help me on this.

    Thanks,
    vamsi.
    Last edited by Daniil; Jul 14, 2015 at 5:19 PM. Reason: [CLOSED]
  2. #2
    Hello,

    Can you please provide some sample code to work on?
  3. #3
    Hi,

    Please find the sample code :

    <%@ Page Language="C#" %>
    
    <%@ Import Namespace="System.Collections.Generic" %>
    <script runat="server">
        
        private void AddField(ModelField field)
        {
            if (X.IsAjaxRequest)
            {
                this.Store1.AddField(field);
            }
            else
            {
                this.Store1.Model[0].Fields.Add(field);
            }
        }
    
        private void BindSet1()
        {
            string now = DateTime.Now.ToLongTimeString();
    
            this.Store1.DataSource = 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}
                                         };
            this.Store1.DataBind();
        }
    
        private void BuildSet1()
        {
            if (X.IsAjaxRequest)
            {
                this.Store1.RemoveFields();
            }
            this.Store1.RebuildMeta();
    
            this.AddField(new ModelField("StringField"));
            this.AddField(new ModelField("IntField", ModelFieldType.Int));
            this.AddField(new ModelField("Timestamp"));
    
    
            this.BindSet1();
            Ext.Net.ListFilter exttrinffilter1 = new Ext.Net.ListFilter();
            
            Column test1 = new Column { DataIndex = "StringField", Text = "String" };
            test1.Filter.Add(exttrinffilter1);
            this.GridPanel1.ColumnModel.Columns.Add(test1);
            
            this.GridPanel1.ColumnModel.Columns.Add(new Column { DataIndex = "IntField", Text = "Int" });
            this.GridPanel1.ColumnModel.Columns.Add(new Column { DataIndex = "Timestamp", Text = "Timestamp" });
    
            if (X.IsAjaxRequest)
            {
                this.GridPanel1.Reconfigure();
            }
        }
    
        private void BindSet2()
        {
            string now = DateTime.Now.ToLongTimeString();
    
            this.Store1.DataSource = new List<object>
            {
                new { IntField1 = 1, StringField = "Set2_1", IntField2 = 1, Timestamp = now },
                new { IntField1 = 2, StringField = "", IntField2 = 2, Timestamp = now },
                new { IntField1 = 3, StringField = "Set2_3", IntField2 = 3, Timestamp = now },
                new { IntField1 = 4, StringField = "", IntField2 = 4, Timestamp = now },
                new { IntField1 = 5, StringField = "", IntField2 = 5, Timestamp = now },
                new { IntField1 = 6, StringField = "Set2_6", IntField2 = 6, Timestamp = now }
            };
    
            this.Store1.DataBind();
        }
    
        private void BuildSet2()
        {
            if (X.IsAjaxRequest)
            {
                this.Store1.RemoveFields();
            }
    
            this.AddField(new ModelField("IntField1", ModelFieldType.Int));
            this.AddField(new ModelField("StringField"));
            this.AddField(new ModelField("IntField2", ModelFieldType.Int));
            this.AddField(new ModelField("Timestamp"));
            this.Store1.RebuildMeta();
    
            this.BindSet2();
            Ext.Net.ListFilter exttrinffilter = new Ext.Net.ListFilter();
            
            this.GridPanel1.ColumnModel.Columns.Add(new Column { DataIndex = "IntField1", Text = "Int1" });
            Column test = new Column { DataIndex = "StringField", Text = "String" };
            test.Filter.Add(exttrinffilter);
            this.GridPanel1.ColumnModel.Columns.Add(test);
            this.GridPanel1.ColumnModel.Columns.Add(new Column { DataIndex = "IntField2", Text = "Int2" });
            this.GridPanel1.ColumnModel.Columns.Add(new Column { DataIndex = "Timestamp", Text = "Timestamp" });
    
    
    
    
            if (X.IsAjaxRequest)
            {
                this.GridPanel1.Reconfigure();
            }
        }
    
        private void RefreshSet()
        {
            switch (this.CurrentSet.Text)
            {
                case "1":
                    this.BindSet1();
                    break;
                case "2":
                    this.BindSet2();
                    break;
            }
        }
    
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.BuildSet1();
            }
        }
    
        protected void RefreshDataSet(object sender, StoreReadDataEventArgs e)
        {
            switch (e.Parameters["set"])
            {
                case "1":
                    this.BuildSet1();
                    this.CurrentSet.Text = "1";
                    break;
                case "2":
                    this.BuildSet2();
                    this.CurrentSet.Text = "2";
                    break;
                default:
                    this.RefreshSet();
                    break;
            }
        }
    </script>
    <!DOCTYPE html>
    <html>
    <head id="Head1" runat="server">
        <title>Grid and Store Reconfigure - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" />
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <h1>
            Grid and Store Reconfigure</h1>
        <ext:GridPanel ID="GridPanel1" runat="server" Title="Grid" Width="600" Height="350">
            <Store>
                <ext:Store ID="Store1" runat="server" OnReadData="RefreshDataSet" IgnoreExtraFields="false">
                    <Model>
                        <ext:Model ID="Model1" runat="server" />
                    </Model>
                </ext:Store>
            </Store>
            <SelectionModel>
                <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" Mode="Single" />
            </SelectionModel>
            <Buttons>
                <ext:Button ID="Button1" runat="server" Text="Load Data1" EnableToggle="true" ToggleGroup="set"
                    Pressed="true">
                    <Listeners>
                        <Click Handler="#{GridPanel1}.store.reload({params:{set:1}});" />
                    </Listeners>
                </ext:Button>
                <ext:Button ID="Button2" runat="server" Text="Load Data2" EnableToggle="true" ToggleGroup="set">
                    <Listeners>
                        <Click Handler="#{GridPanel1}.store.reload({params:{set:2}});" />
                    </Listeners>
                </ext:Button>
                <ext:Button ID="Button3" runat="server" Text="Refresh Current Data">
                    <Listeners>
                        <Click Handler="#{GridPanel1}.store.reload();" />
                    </Listeners>
                </ext:Button>
            </Buttons>
            <Plugins>
                <ext:GridFilters>
                </ext:GridFilters>
            </Plugins>
        </ext:GridPanel>
        <ext:Hidden ID="CurrentSet" runat="server" Text="1" />
        </form>
    </body>
    </html>
    Please help me out , How to filter only blank records.

    Thanks,
    Vamsi.
  4. #4
    Thanks for providing the sample. Reproduced; There seems to be a mismatch between the blank cell value and the filter value. Also noticed that the blank filter list item does not display correctly.

    As a quick fix, you can use &nbsp; instead of "" as the blank value.

    We are further investigating and it will probably be reported as a bug.

    Hope it helps.
  5. #5
    Thanks for response,

    I have replaced "&nbsp;" instead of "" still there was an filtering issue..

    Blank records are not filtering .

    I have provided sample data but i'm using data table which thousand of records in database and which I can't replace the "&nbsp; instead of "" in datatable.

    Please help me out on this and its very urgent for us.

    Thanks,
    Vamsi.
  6. #6
    We will try to find a solution.

    Ideally, it would be nice if you provide us with a test case to reproduce that.
    I have replaced "&nbsp;" instead of "" still there was an filtering issue..
    Just to test a solution if we find any.
  7. #7
    Let me provide you with a working sample where Ext.Net takes care of the conversion for you. It is still a quick fix but please, let me know if it works 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 id="Head1" runat="server">
        <title></title>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <h1>
            Grid and Store Reconfigure</h1>
            <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>
                </ext:Store>            
            </Store>
            <ColumnModel>
                <Columns>
                    <ext:Column runat="server" DataIndex="StringField" Text="String">                    
                        <Filter>
                            <ext:ListFilter />
                        </Filter>
                    </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 />
            </Plugins>
        </ext:GridPanel>
        </form>
    </body>
    </html>
    Hope it helps.
  8. #8
    Thank you and works as expected .


    Once again thank you , Please close the thread
  9. #9
    Hi,

    Sorry for reopening the issue ..

    It's working as expected but there was an issue while editing the record its showing up "&nbsp;" instead of blank.

    Please give me an solution to overcome this issue

    Thanks,
    Vamsi.
  10. #10
    Yes, please note that Convert does exactly this; &nbsp; is therefore the data value.

    So, if you add a TextField editor to the grid column and enter edit mode, you will find a blank character exists but &nbsp; is not itself visible (i.e., there is no "&nbsp;" visible in the editor), if that's what you mean.

    Also, I suggest you trim the string value when you save data in the database.

    Again, as said, this is a quick fix; We are working on a more appropriate solution.
Page 1 of 2 12 LastLast

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