Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
ASP.Net MVC - IGGrid date filtering - Cannot read property 'day' of null
posted

When trying to filter a column of type date, I get the following error

infragistics.ui.grid.filtering.js:23 Uncaught TypeError: Cannot read property 'day' of null
at Class._findDateMatch (infragistics.datasource.js:38)
at Class._findMatch (infragistics.datasource.js:38)
at Class.filter (infragistics.datasource.js:38)
at e.<computed>.<computed>._filterDataSource (infragistics.ui.grid.filtering.js:23)
at e.<computed>.<computed>._filterDataSource (VM525 jquery-ui.min.js:6)
at e.<computed>.<computed>._filterInternal (infragistics.ui.grid.filtering.js:23)
at e.<computed>.<computed>._filterInternal (VM525 jquery-ui.min.js:6)
at e.<computed>.<computed>._selectDropDownItem (infragistics.ui.grid.filtering.js:25)
at e.<computed>.<computed>._selectDropDownItem (VM525 jquery-ui.min.js:6)
at HTMLLIElement.d (VM521 jquery.min.js:2)

I am setting the GridModel in my controller and sending it as a model to the front end. I came across https://ko.infragistics.com/community/forums/f/ignite-ui-for-javascript/110621/error-on-date-column-filter and tried to set the value for the column cell as a string using "date.toString(date.ToString("yyyy-MM-ddTHH:mm:ssZ")" rather than a date time object. However, the datasource in the  front end still contains the format /Date(1234656000000)/). 

Please provide a solution for this. Also, can you provide a sample where the filtering for the date type column is set on the backend using c# code. Most of the source that I find for reference uses javascript. 

  • 29417
    Offline posted

    Hello Nikitha,

    Thank you for posting in our forum.

    Could you provide some additional information such as:

    • Which version of the product are you currently using? Could you check both the versions of the client-side js files and the MVC Wrapper dll and ensure both have matching versions (for example, both are 19.2)?
    • Are you binding the grid data via the GridModel, via a separate Controller Action marked with the GridDataSourceAction attribute or in another way?

     I’ve attached a small sample for your reference that uses the latest version of 19.2 for the MVC wrapper (Infragistics.Web.Mvc.dll) - 19.2.23 and the latest version of the scripts - 19.2.25.

    1638.igGrid_BindingDates.zip

    In the sample the data is bound via the GridModel and the Date column is set to be of type “date”:

     public ActionResult Index()

            {

                GridModel model = new GridModel();

              

                model.AutoGenerateColumns = false;

                model.Columns.Add(new GridColumn("ID", "ID", "number", "200px"));

                model.Columns.Add(new GridColumn("Name", "Name", "string", "200px"));

                model.Columns.Add(new GridColumn("Date", "Date", "date", "200px"));

     

                model.DataSource = GetData().AsQueryable();

                model.DataBind();

     

                model.Features.Add(new GridFiltering());

                return View(model);

            }

     

    As a result the date fields are serialized on ISO format when send to the client:

    $(function () {$('#Grid1').igGrid({ dataSource: {"Records":[{"ID":0,"Name":"Name0","Date":"2020-02-04T08:45:05.0942137Z"},

    And data operations on them, like filtering, work as expected.

    Please refer to the sample and let me know if you are aiming to achieve something similar. If the sample is not an accurate representation of what you are trying to achieve then please feel free to modify and send it back.

    Regards,

    Maya Kirova