Friday, July 20, 2012

How to change the date format in Telerik mvc grid inline edit mode

Telerik mvc grid inline edit mode” finally I got a solution by which we can change the date format while using Telerik mvc grid inline edit mode. Here is the simple code.

1.  Just add a client side event to your grid

.ClientEvents(events => events
2.  Add this event in your javacript code

function onEdit(e) {
        var dataItem = e.dataItem;
        var sDate = new Date(dumpDate(dataItem));
        if (isNaN(sDate.getMonth())) {
            sDate = new Date();

        $('#GridDate').val($.telerik.formatString('{0:MM/d/yyyy}', sDate));

function dumpDate(obj) {
        var result = [];
        $.each(obj, function (key, value) { if (key.toString() == "GridDate") { result.push(value); } });
        return result;

 Here GridDateis a property in my model so you can replace this with  your date name.

Hope this help someone. Thanks

No comments:

Post a Comment