Kendo Grid inline edit with Datetime DatePickerFor

2019-05-24 08:15发布

问题:

kendo inline cell edit not support for datetime format. I need "dd/MMM/yyyy" data format but kendo grid shows "the filed date must be a date" error. can you please advice me to what to do

回答1:

You can use a custom editor to do this.

References:

  • Grid Custom Editing
  • DatePicker.format
  • Date Formatting

The code would look something like this (not tested, but it should be close enough to give you the right idea):

var customDateEditor = function (container, options) {
    $('<input />')
        .appendTo(container)
        .kendoDatePicker({
            format: "dd/MMM/yyyy"
        });
};

$("#grid").kendoGrid({
    ...
    columns:[
        {
            field: "myDate",
            format: "dd/MMM/yyyy",
            editor: customDateEditor
        }
    ]
});