We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Filtering date js

Hi!

We need filter grid in side client but we can to do run.

We have a Hierarchy Grid and we try apply filter:

function filterDate(btnStatus)
    {
       
        // AÑADIR FILTROS DE FECHAS
        //filterGrid("FechaPrevista", "28/06/2015", btnStatus.isChecked, ej.FilterOperators.greaterThan);

        $.each(gridsChild, function (s, e) {
            var gridId = "#" + e;
            var gridObj = $(gridId).data("ejGrid");
            gridObj.model.filterSettings.filteredColumns = [];
            gridObj.refreshContent();


            var date = new Date(2015, 06, 15, 0, 0, 0, 0);
            //var dateDouble = date.getTime();
            gridObj.filterColumn("FechaPrevista", ej.FilterOperators.greaterThan, date, "or");

            onCreateRowChildres(e);
        });
        
    }

But never filter date... i attach project sample.

Thanks!

Attachment: TestSyncFusion_511fd772.zip

1 Reply

AR Ajith R Syncfusion Team June 26, 2015 11:48 AM UTC

Hi David,

Thanks for using Syncfusion products.

Query: We need filter grid in side client but we can to do run. But never filter date

We have analyzed your code snippet and found that you have not set the match case parameter value in the filterColumn function which is the cause of the issue. When the filterColumn function doesn’t have the match case parameter for filtering date type column, it will compare the date value as string and return the result based on the string value. So we suggest you to set the match case as true in the filterColumn function to resolve the issue.

Please refer the below code snippet for further details.


function filterDate(btnStatus)

    {            

        $.each(gridsChild, function (s, e) {

            -------

            -------

            var date = new Date(2015, 06, 15, 0, 0, 0, 0);           

            gridObj.filterColumn("FechaPrevista", ej.FilterOperators.greaterThan, date, "and", true);           

        });

       
    }


Note: Since you have set month value as 06 in the Date object, its corresponding month is July from javascript Date object and the filter result will show “No records to display” as per your records in the Grid.

Please refer the below link to know further  details about month in javascript object.

https://msdn.microsoft.com/library/cd9w2te4(v=vs.94).aspx

For your convenience we have modified your sample and the same can be downloaded from the below link.

Sample Link: http://www.syncfusion.com/downloads/support/forum/119469/ze/TestSyncFusion-520701269

Please let us know if you have any concerns.

Regards,
Ajith R

Loader.
Live Chat Icon For mobile
Up arrow icon