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
                            .OnEdit("onEdit")
                            )
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));
        $('#GridDate').focus();
    }


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

Comments

Popular Posts

GREYCstoration Oil Paint plugin for Photoshop

Service Bus Gateway service stuck at Starting

PowerApps SubmitForm not clearing People Picker value

Apple iPhone sending SMS automatically 00447786205094

SharePoint online hub navigation not updating for other users