This is a migrated thread and some comments may be shown as answers.

Could not able to insert multiple datetimepicker in grid

2 Answers 16 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Sagar
Top achievements
Rank 1
Sagar asked on 16 Feb 2021, 09:23 AM

I would like to add DateTimePicker into row dynamically while adding new row on the clicking event. Also While doing so previous data gets cleared.

 

Here is code below:

@(Html.Kendo().Grid(Model.InOutTimes)
                    .Name("InOutTimesGrid")
                    .Columns(columns =>
                    {
                        columns.Bound(c => c.ID).Hidden();
                        columns.Bound(c => c.NoteID).Hidden();
                        columns.Bound(c => c.InDateTime).ClientTemplate(Html.Kendo().DateTimePicker()
                                                            .Name("InDateTime")
                                                            .Min(new System.DateTime(1970, 1, 1, 0, 0, 0)) // Epoch
                                                            .Format("MM-dd-yyyy HH:mm")
                                                            .TimeFormat("HH:mm")
                                                            .ToClientTemplate().ToString()

                                                        );
                        columns.Bound(c => c.OutDateTime).ClientTemplate(Html.Kendo().DateTimePicker()
                                                            .Name("OutDateTime")
                                                            .Min(new System.DateTime(1970, 1, 1, 0, 0, 0)) // Epoch
                                                            .Format("MM-dd-yyyy HH:mm")
                                                            .TimeFormat("HH:mm")
                                                            .ToClientTemplate().ToString()
                                                        );
                    })
                    .DataSource(datasource => datasource.Ajax().Read("InOutTimes_Read", "ClientNotesVirtual"))

 

Am I missing something. Please help!!.

2 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 18 Feb 2021, 08:55 AM

Hello Sagar,

 

Thank you for writing to us.

I can see that you are using a ClientTemplate which is suitable for View mode of the grid. But for the Edit and Insert modes, you should use the EditorTemplate as demonstrated here:
https://demos.telerik.com/aspnet-mvc/grid/editing-custom

The editor is located in this file:
ClientCategory.cshtml

In your case it will be a date picker.

And in your Model file you can add the UIHint attribute:

        [UIHint("ClientCategory")]
        public DateTime? YourField
        { 
            get; 
            set; 
        }

Feel free to give it a try and let me know if it helps you. If you have different requirements or further instructions, feel free to share them.

 

Regards,
Eyup
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Sagar
Top achievements
Rank 1
answered on 19 Feb 2021, 09:37 AM

Thank You So Much.

Solution worked for me.

Tags
Date/Time Pickers
Asked by
Sagar
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Sagar
Top achievements
Rank 1
Share this question
or