Add filter by date to kendo grid with dynamic columns

1 Answer 355 Views
Date/Time Pickers Filter Grid
Miguel
Top achievements
Rank 1
Miguel asked on 13 Oct 2021, 05:06 PM | edited on 13 Oct 2021, 05:06 PM

Hello, I'm trying to add a date filter to a dynamic column but my filter it's not applied, always apply the default string filter.

This is my current code to create the grid: 

And this is current result:

 

Is there any way to implement this(date filter in dynamic grid)?

BR, Miguel Machado


 

Miguel
Top achievements
Rank 1
commented on 13 Oct 2021, 05:20 PM

I try this too.

.Filterable(ftb => ftb.Cell(cell => cell.Template("DateTimeFilter")));

<script>
    function DateTimeFilter(args) {
        args.element.kendoDateTimePicker({
            timeFormat: "HH:mm:ss",
            interval: 0.5
        })
    }
</script>

But I have same result.

1 Answer, 1 is accepted

Sort by
1
Accepted
Tsvetomir
Telerik team
answered on 18 Oct 2021, 07:26 AM

Hello, Miguel,

In general, when the grid is bound to a dynamic, the data types that are different from the string data type should be declared additionally in the model of the data source. For instance:

 .Model(model =>
                          {
                              foreach (System.Data.DataColumn column in Model.Columns)
                              {
                                  var field = model.Field(column.ColumnName, column.DataType);
                              }
                          })

If you know the specific field name, you can go ahead and specify it in the model as of type DateTime. This way, the column will be treated as a date column and the filter menu will render date pickers out of the box. 

 

Kind regards,
Tsvetomir
Progress Telerik

Remote troubleshooting is now easier with Telerik Fiddler Jam. Get the full context to end-users' issues in just three steps! Start your trial here - https://www.telerik.com/fiddler-jam.
Tags
Date/Time Pickers Filter Grid
Asked by
Miguel
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
Share this question
or