[OPEN] [#1361] [3.3.0] Problem with FilterHeader plugin in GridPanel

  1. #1

    [OPEN] [#1361] [3.3.0] Problem with FilterHeader plugin in GridPanel

    Hello

    I have problem with filtering rows using FilterHeader plugin when type of ModelField is ModelFieldType.Auto and column contains numbers.

    When I type in something in the filter field, an error occurs:
    JavaScript runtime error: Object doesn't support property or method 'toLowerCase'
    When I set type = ModelFieldType.Int, filtering is OK but NULLs is store are converted to 0 what is not desired.

    Ext.Net ver. 3.3.0

    test_filters.aspx
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="test_filters.aspx.cs" Inherits="test_filters" %>
    
    <!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></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
        </div>
        </form>
    </body>
    </html>
    test_filters.aspx.cs
    using System;
    using System.Collections.Generic;
    using System.Web;
    using Ext.Net;
    
    public class FiltersTestData
    {
      public static List<object> Data
      {
        get
        {
          return new List<object>
          {
            new { ID = 10 },
            new { ID = 20 },
            new { ID = System.DBNull.Value}
          };
        }
      }
    }
    
    public partial class test_filters : System.Web.UI.Page
    {
      protected void Page_Load(object sender, EventArgs e)
      {
    
        ResourceManager res_man = new ResourceManager() { ID = "res_man" };
        res_man.IDMode = IDMode.Explicit;
        res_man.ViewStateMode = System.Web.UI.ViewStateMode.Disabled;
        res_man.DirectMethodNamespace = "net";
        form1.Controls.Add(res_man);
    
        GridPanel grid1 = new GridPanel() { ID = "grid1" };
        grid1.Plugins.Add(new FilterHeader());
    
        grid1.ColumnModel.Columns.Add(new Column() { DataIndex = "ID", Text = "Id" });
    
        Store store1 = new Store() { ID = "store1" };
    
        Model model1 = new Model();
        model1.Fields.Add(new ModelField("ID", ModelFieldType.Auto));
    
        store1.Model.Add(model1);
        grid1.Store.Add(store1);
    
        if (!X.IsAjaxRequest)
        {
          store1.DataSource = FiltersTestData.Data;
          store1.DataBind();
        }
    
        form1.Controls.Add(grid1);
    
      }
    }
  2. #2
    Hello @pk.net!

    Nice test case, simple and clear!..

    But is there a reason forcing model type to be string won't work for you? I mean, defining your column with:

    model1.Fields.Add(new ModelField("ID", ModelFieldType.String));
    This will allow nulls as well as partial filtering by the numbers.

    Alternatively, if you really need it as an int for whatever reason, you can convert 'null' or empty values to an unlikely number (like -1 when you are dealing with values only >=0) and then add a 'renderer' to the column, in which it would return an empty string every time that number matches it.

    Example using renderer on grid panels: Simple Array Grid Panel.

    I hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hello fabricio.murta!

    Thanks for your reply, finally I defined column as ModelFieldType.String. The only disadvantage is that the filter behaves as a string filter (it isn't possible to filter values for example greater than 10).

    In my opinion, when a column is defined as "Int", null's shoudn't be converted to 0 and when column is defined as "Auto", there shoudn't be javascript error. Maybe You can fix it in the future?

    Best regards
    P.K.
  4. #4
    Hello!

    You got it! Issue #1361 created to track the issue with the incorrect type handling from FilterHeader when the model's type is automatic and data is integer!

    As for integer dealing with nulls, well, null is not an integer, the field needs an integer so there's not much that can be done here. Need special behavior? The renderer is there to help!

    I hope this helps!
    Fabrício Murta
    Developer & Support Expert
  5. #5
    This helps :) Thank you.

    Best regards
    PK

Similar Threads

  1. [CLOSED] FilterHeader plugin : override Operator of Parameters["filterheader"]
    By matrixwebtech in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Apr 17, 2015, 1:55 PM
  2. [CLOSED] FilterHeader : FilterHeader for specific columns in gridpanel
    By matrixwebtech in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 29, 2015, 12:20 PM
  3. Default values in FilterHeader Plugin
    By iomega55 in forum 2.x Help
    Replies: 1
    Last Post: Oct 14, 2014, 1:44 PM
  4. Hide/Show FilterHeader Plugin
    By ADV in forum 2.x Help
    Replies: 2
    Last Post: Dec 24, 2013, 1:46 AM
  5. Replies: 1
    Last Post: Nov 23, 2013, 3:09 PM

Posting Permissions