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

Setting initial value of TimePicker

8 Answers 475 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Veteran
Iron
Rob asked on 02 Aug 2016, 04:26 AM

Hi Guys

This stupid little issue is taking up way way too much time for me to resolve..

I am setting a timepicker as follows:

  <td class="tg-7uzy">

                @Code
                    With Html.Kendo().TimePicker()
                        .Name("1Open")
                        .Events(Function(events) events.Change("settime"))
                        .Value(New TimeSpan(0, Model.Hours(1).open, 0))
                        .Min(New TimeSpan(0, 0, 0))
                        .Max(New TimeSpan(0, 0, 0))
                        .Render()
                    End With
                End Code
            </td>

The result is as per the attached screen shot.

It 'looks like' the values are set right as the timepickers have the correct times , but when you drop down, it always starts at midnight and the current time is not highlighted.  I assume the timepicker needs the value to be set with AM or PM .. but that can't be done from a TimeSpan or a datetime.. the am pm always has dots ( a.m.  , p.m.)

 

If tried adding .Format("HH:mm:tt") and  .ParseFormats(New String() {"HH:mm:tt"}) etc, but I just can't get it to work. ( I've tried allot more formats than just these, I've tried "HH:mm tt" ,"HH:mm t.t." ( cause it's the dots around the am pm which seems to be whats stopping.))

Feeling a bit stupid having to ask this as it seems to be a straightforward thing.

I'm sure I will have a Face palm moment when shown the error in my ways.. but I've got to the point of not caring! :)

Cheers

Rob

 

8 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 03 Aug 2016, 02:42 PM

HelloRob,

I tried to replicate the behavior, however, I was not able to. Check out the online example where the initial time is selected when you open the dropdown.

http://demos.telerik.com/aspnet-mvc/timepicker/index


Please let me know what needs to be different in order to replicate the behavior you are observing.


Regards,

Viktor Tachev
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Rob
Top achievements
Rank 1
Veteran
Iron
answered on 03 Aug 2016, 09:09 PM

You reference is setting a timepicker from a string.. I don't want to store times as strings.

I note from the docs that this method is a TimeSpan

Methods
Value(System.Nullable<System.TimeSpan>)

Sets the value of the timepicker input 

 

I am storing the times as 'minutes since midnight'

Hence I have setting 

.Value(New TimeSpan(0,600, 0))

compared to the example you linked to which is

.Value("10:00 AM")

Thanks

Rob

 

0
Viktor Tachev
Telerik team
answered on 05 Aug 2016, 12:44 PM
Hi Rob,

Please make sure that you are using the latest version of the components. The current release is 2016.2.714. Upgrade KendoUI and the time should be focused as expected.

I made a sample video of the behavior I am seeing on my end with the latest release. Check it out here.

Regards,
Viktor Tachev
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Rob
Top achievements
Rank 1
Veteran
Iron
answered on 06 Aug 2016, 10:00 PM

Thanks

So at least I know it should work how I am trying! :)

I have( already had) the very latest everything here and not the same results.

To test;

I just created a new Telerik  ASP.NET MVC Application. ( screen shot attached)

Added the same code as you in the index screen 

(Screen shot attached)

Hit run and it doesn't work. :(

 

Maybe this is a regional / Time display issue / Bug? 

Thanks

 

Rob

0
Rob
Top achievements
Rank 1
Veteran
Iron
answered on 06 Aug 2016, 10:09 PM

Sorry , some of those pictures got screwed up somehow.. attach some new ones. 

I considered adding the new project, but it is literally a new Telerik ASP project template with the single div added.. seems pointless!

Thanks

 

Rob

0
Rob
Top achievements
Rank 1
Veteran
Iron
answered on 07 Aug 2016, 09:12 PM

I can confirm this is a Regional /time format issue.

If I change my system to to UK time formats ( and others)  it works.

It seems that the standard NZ time format with the lower case am pm with the dot's is causing the issue.  ( Not sure what other regions are affected)

I can't have a solution that only works in some regions obviously.

Can you suggest any nice ways of handling this?

Thanks

Rob

 

 

 

0
Rob
Top achievements
Rank 1
Veteran
Iron
answered on 07 Aug 2016, 11:02 PM

I wish I could edit rather than more posts..lol

FYI: I have carried on with this project and the Timepickers are now 'fors'

@Code
                 With Html.Kendo().TimePickerFor(Function(f) f.sun_open)
                     .Name("0Open")
                     .Events(Function(events) events.Change("settime"))
                     .Min(New TimeSpan(0, 0, 0))
                     .Max(New TimeSpan(0, 0, 0))
                     .Render()
                 End With
             End Code

Changed the Model to be timespan obviously.

When displayed , the time picker is showing the correct time in the NZ time format , but once again it is not actually setting the value of the time picker. :(

 

Regards

Rob

0
Maria Ilieva
Telerik team
answered on 09 Aug 2016, 04:06 PM
Hi Rob,

In this case it will be best to open a official support ticket and send us isolated runnable version of your applictaion that demonstrates the problem. Thus we will be able to replicate the issue locally and advise you further.

Regards,
Maria Ilieva
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Date/Time Pickers
Asked by
Rob
Top achievements
Rank 1
Veteran
Iron
Answers by
Viktor Tachev
Telerik team
Rob
Top achievements
Rank 1
Veteran
Iron
Maria Ilieva
Telerik team
Share this question
or