Bind DateTimePicker to DataTimeOffset attribute

2 posts, 0 answers
  1. Hemal Shah
    Hemal Shah avatar
    2 posts
    Member since:
    May 2010

    Posted 04 Dec 2014 Link to this post

    We have all our date fields in our Oracle DB defined as "Timestamp with Timezone". We use EF and LINQ to hydrate our VM from the DB. The VM gets populated correctly however when I try to bind a DateTimeOffset attribute to DateTimePicker component it fails.

    Can you tell me what could I be doing incorrectly. If this is not supported does someone else have any suggestions that I can try.

    Here is what I have so far 

    VM
    [DisplayName("Inactivate Date")]
    public DateTimeOffset? inactivateDate { get; set; }

    [DisplayName("Inactivate Date")]public DateTimeOffset? inactivateDate { get; set; }  
    public DateTimeOffset? activateDate { get; set; }

    [DisplayName("Energizing Date")]
    public DateTimeOffset? energizingDate { get; set; }

    View Template
    <div class="form-group">
        @Html.LabelFor(model => model.energizingDate, new { @class = "control-label col-xs-2" })
        <div class="col-xs-2">
            @Html.EditorFor(model => model.energizingDate)
            @Html.ValidationMessageFor(model => model.energizingDate)
        </div>
        <div class="col-xs-3">
            <div class="form-group">
                @Html.LabelFor(model => model.activateDate, new { @class = "control-label col-xs-4" })
                <div class="col-xs-7">
                    @Html.EditorFor(model => model.activateDate)
                    @Html.ValidationMessageFor(model => model.activateDate)
                </div>
            </div>
        </div>
        <div class="col-xs-3">
            <div class="form-group">
                @Html.LabelFor(model => model.inactivateDate, new { @class = "control-label col-xs-4" })
                <div class="col-xs-7">
                    @Html.EditorFor(model => model.inactivateDate)
                    @Html.ValidationMessageFor(model => model.inactivateDate)
                </div>
            </div>
        </div>
    </div>


    DAO
    var x = dao.CONNECTIVITY_UNIT
                            .Join(dao.OP_AREA_ORG, cu => cu.OP_AREA_CODE, oa => oa.OP_AREA_CODE, (cu, oa) => new { CONNECTIVITY_UNIT = cu, OP_AREA_ORG = oa })
                            .Where(w => w.CONNECTIVITY_UNIT.UNIT_TYPE.Equals("SUBSTATION"))
                            .Where(w => w.CONNECTIVITY_UNIT.IS_ACTIVE_FLAG.ToUpper().Equals("Y"))
                            .Where(w => w.CONNECTIVITY_UNIT.ABBR.ToUpper().Equals("BRA"))
                            .Select(c => new SubstationVM
                            {
                                connectivityUnitID = c.CONNECTIVITY_UNIT.CONNECTIVITY_UNIT_ID,
                                energizingDate = c.CONNECTIVITY_UNIT.ENERGIZING_DATE.Value.DateTime,
                                activateDate = c.CONNECTIVITY_UNIT.ACTIVATE_DATE.Value.DateTime,
                                //inactivateDate = c.CONNECTIVITY_UNIT.INACTIVATE_DATE.Value.DateTime,
                                updateTime = c.CONNECTIVITY_UNIT.UPDATE_TMSTMP
                            })
                            .OrderBy(o => o.substationABBR)
                            .ToList();


    This fails when it has to find to the DateTimePicker component. I tried to bind it to plain old TextBox and it works fine.

    What am I missing.
  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 08 Dec 2014 Link to this post

    Hello Hemal,

    Sadly the DateTimeOffset type is still not supported by the Date/Time picker widgets of Kendo.

    You need to first cast the type to DateTime.

    Regards,
    Petur Subev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top