Search code examples
c#datekendo-uikendo-gridkendo-asp.net-mvc

Kendo grid - date field is non editable


I have kendo grid which has an 'end_date' column. The date is coming from server and it was getting converted to local timezone. To fix this issue I have used this code

Server side:

DateTime time = DateTime.Now();
string end_date = time.ToString("MM/dd/yyyy");

client side:

columns.Bound(c => c.end_date).Format("{0:MM/dd/yyyy}").Filterable(ftb => ftb.Cell(cell => cell.ShowOperators(true))).Width(225);

But by using this approach , the end_date column in becoming non-editable. How can I make it editable and filterable?


Solution

  • The issue is resolved

    Model class

    DateTime end_date {get;set;}
    
    [DataType(DataType.Date)] // Annonate with this
    string end_date_only = end_date.ToString("MM/dd/yyyy");
    

    in cshtml: Use end_date and end_date_only as shown below with ClientTemplate

    columns.Bound(c => c.end_date).Format("{0:MM/dd/yyyy}").ClientTemplate("#= kendo.toString(kendo.parseDate(end_date_only ), 'MM/dd/yyyy') #").Filterable(ftb => ftb.Cell(cell => cell.ShowOperators(true))).Title("End Date").Width(225);