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

Getting date only from grid inline date picker

7 Answers 85 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Henrik
Top achievements
Rank 1
Henrik asked on 31 May 2017, 06:19 AM

Hi,

 

I have a grid with inline editing and a date field. Model:

        [DataType(DataType.Date)]
        public DateTime RelevantDate { get; set; }

Grid:

cols.Bound(p => p.RelevantDate).Format("{0:yyyy-MM-dd}").EditorTemplateName("DatePicker").Title("Date of change").Width(120);

 

The DatePicker template is in the Views\Shared\EditorTemplates folder.

 

My problem is that when I select a date in the grid and hit Submit the parameter model.RelevantDate in the controller method has the selected date and the current time i.e. 2016-04-01 08:19:41. What I would like to have is the date only: 2016-04-01 00:00:00. Is this possible?

 

Best regards,

Henrik

7 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 31 May 2017, 02:26 PM
Hello Henrik,

The Kendo DatePicker uses JavaScript Date object. Based on the user input it creates Date object with the clients data, since the DatePicker is only for dates, the hours value of the object remains with it's default value. I tried to recreate you situation but it works as expected on my end and the hours are always with their default value. 

Make sure there is not custom logic that sets the hours. In case there is no such logic please send us runnable project or isolated sample where the issue occurs so we can investigate your exact case and help you more efficiently.

Regards,
Georgi
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Henrik
Top achievements
Rank 1
answered on 01 Jun 2017, 08:43 AM

Hi Georgi,

I tried to attach a project, but to get it small enough I had to delete all the kendo-files. Can you add the necessary files at your end? The Web\Content\Kendo and scripts\kendo directories.

 

Best regards,

Henrik

0
Henrik
Top achievements
Rank 1
answered on 01 Jun 2017, 08:45 AM
...and trying to attach the zip-file again...
0
Henrik
Top achievements
Rank 1
answered on 01 Jun 2017, 08:46 AM
...and trying to attach the file again...
0
Henrik
Top achievements
Rank 1
answered on 01 Jun 2017, 08:47 AM

I keep getting an error when trying to attach a sample project. Is there another way I can send the file?

 

Henrik

0
Georgi
Telerik team
answered on 02 Jun 2017, 07:34 AM
Hello Henrik,

Please note that attaching archives in a forum thread is not possible. Nevertheless you can upload the project to a file sharing provider (e.g. DropBox, Google Drive) that is convenient to you and send us the download link. 

Alternatively, you can open a support ticket and attach the project there. Note that there is a file size limit of 40MB.


Regards,
Georgi
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Henrik
Top achievements
Rank 1
answered on 07 Jun 2017, 12:40 PM

Thanks, support ticket submitted.

 

Henrik

Tags
Grid
Asked by
Henrik
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Henrik
Top achievements
Rank 1
Share this question
or