简体   繁体   中英

How to add DatePicker in ClientTemplate for Kendo MVC Grid

I am trying to port my code from syncfusion to telerik kendo MVC UI, I need to show Datepicker in Grid cell, and for which I have done in grid column as:

columns.Add("TemplateCol").Title("Out of date").TemplateColumn(true).TemplateName("TemplateOutOfDate");

and for TemplateOutOfDate I have made in seperate .cshtml file as

@Html.Syncfusion().DatePicker("OutOfDate" + Model.ID.ToString(), Model.OutOfDate).DefaultDate(Model.OutOfDate).DisplayDefaultDateOnLoad(true).DateFormat(Model.DefaultDateFormat).Width(75).OnSelect("onselect")

This .cshtml work fine in Syncfusion grid but when I port this code to Kendo().Grid it is not working So please tell me on we can achieve this using ClientTemplate to add DatePicker in Kendo Grid.

Thanks,Ajit

Try this

columns.Bound(c => c.BirthDate).HtmlAttributes(new
    {
        @class = "templateCell"

    }).ClientTemplate(
     Html.Kendo().DatePicker()
      .Name("FDPicker_#=ID#")
      .Format("{0:dd/MM/yyyy}")
      .HtmlAttributes(new { data_bind = "value:BirthDate" })
      .ToClientTemplate().ToString()
      ).Format("{0:dd/MM/yyyy}");

More Details

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM