Date ClientTemplate and EditorTemplateName for Nullable or 0 Dates

2 posts, 0 answers
  1. Cynthia
    Cynthia avatar
    13 posts
    Member since:
    Apr 2012

    Posted 16 Apr 2013 Link to this post

    In our database, we use 0 (which resolves as 1/1/1900) for dates.

    We don't have nullable dates.

    What is the best practice such that dates that come into the model is 0 (or1/1/1900), format so in display mode they appear as "--" or "n/a" or "", while in edit mode, the control shows an empty box, instead of 1/1/1900?

  2. Vladimir Iliev
    Vladimir Iliev avatar
    2199 posts

    Posted 18 Apr 2013 Link to this post

    Hi Cynthia,

    This is possible using ClientTemplate(for the display mode) and Edit event(for edit mode) to check if the current date is equal to your custom date to apply custom template / empty the editor. Please check the example below:

    Grid configuration:

        columns.Bound(p => p.OrderDate).Format("{0:d}").ClientTemplate("#=formatDate(OrderDate)#");
        columns.Command(c => {
    .Events(e => e.Edit("onEdit"))

    $(function () {
        formated1900 = kendo.format("{0:d}", new Date(1900, 0, 1));
    function onEdit(e) {
        var formatedOrderDate = kendo.format("{0:d}", e.model.OrderDate);
        //consider handle the user and server time offset:
        if (formated1900 == formatedOrderDate) {
    function formatDate(OrderDate) {
        var formatedOrderDate = kendo.format("{0:d}", OrderDate);
        //consider handle the user and server time offset:
        if (formated1900 == formatedOrderDate) {
            return "--";
        else {
            return formatedOrderDate;

    Kind Regards,
    Vladimir Iliev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top