I need to change the date format in the grid filter context menu. After choosing a date from calendar, it gets displayed in the text box. The default format is 'm/dd/yyyy' which I want to change to a dynamically defined format. We allow user to set date format preferences in our website. It works fine for data. I need to do the same for grid search filter.
This is a server side grid.
8 Answers, 1 is accepted
The simplest option is to customize the Grid filter UI by creating your own picker with any needed settings applied:
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.OrderViewModel>()
.Name(
"grid"
)
.Columns(columns =>
{
columns.Bound(p => p.OrderID).Filterable(
false
);
columns.Bound(p => p.Freight);
columns.Bound(p => p.OrderDate).Filterable(filterable => filterable.UI(
"orderDateFilter"
));
columns.Bound(p => p.ShipName);
columns.Bound(p => p.ShipCity);
})
<script>
function
orderDateFilter(element) {
element.kendoDatePicker({
format:
"MMM dd, yyyy"
// set custom defined format
});
}
</script>
Regards,
Tsvetina
Progress Telerik


Hi Mathews,
The filter customization of the Kendo UI Grid would happen with the help of the filterable.ui option. An example of this customization could be found here:
https://dojo.telerik.com/udOQAwUX
In case further assistance is required, let me know.
Kind regards,
Tsvetomir
Progress Telerik

Hi Mathews,
Thank you for specifying that you are looking for an example that features the DatePicker widget instead of the DropDownList. In general, you could modify the filterable.ui handler according to your preferences. For instance:
filterable:{
ui:function(el){
el.kendoDatePicker({
format: "MMM dd, yyyy" // set custom defined format
});
}
}
Here is the updated Dojo sample:
https://dojo.telerik.com/otIjUXOV
Best regards,
Tsvetomir
Progress Telerik

Hello, Аlex,
In KendoReact this will require using a custom filter component where the developer can set the required format to the DatePicker used for filtering:
https://www.telerik.com/kendo-react-ui/components/grid/filtering/#toc-custom-filter-cells
As React recommends small reusable components, making a full cell only to change the format may seem a lot, but in the long run, this custom cell can be reused in many Grids and if another common change is needed it can be done to this cell and then applied to all other instances.
Regards,
Stefan
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.