New to Kendo UI for jQuery? Download free 30-day trial

Displaying a Blank Cell Instead of 01/01/0001 in Date Columns of the Grid

Environment

Product Progress® Kendo UI® Grid for ASP.NET MVC
Version 2019.3.1023

Description

I want to display a blank value instead of 01/01/0001 in a Grid when the date field is null or contains the minimum value.

Solution

To achieve this behavior, you can use a ClientTemplate and a JavaScript function to handle the display logic. Here's an example:

  1. In the Grid configuration, add the following column definition:
columns.Bound(p => p.OrderDate).ClientTemplate("#=orderDetails(data)#");
  1. Define the orderDetails JavaScript function:
function orderDetails(order) {
    var minDate = new Date('0001-01-01T00:00:00Z');
    minDate.setDate(minDate.getDate() + 1);

    if (order.OrderDate < minDate) {
        return "";
    } else {
        return kendo.toString(order.OrderDate, "g");
    }
}

This function checks if the OrderDate value is less than the minimum date value (01/01/0001). If it is, it returns an empty string. Otherwise, it formats the OrderDate using the "g" format and returns the result.

Now, the Grid will display a blank value instead of 01/01/0001 when the date field is null or contains the minimum value.

More Grid Resources

See Also

In this article