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

Negative values in TimeSpanPicker

6 Answers 210 Views
TimeSpanPicker
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 15 Feb 2016, 03:30 PM

Hello,

 I was wondering if there is any way to set up a TimeSpanPicker so that negative values can be provided?

I tried setting the "Minimum" option on the components to a negative value, but it seems this isn't respected and the minimum remains at 0.

 Any help would be appreciated

Cheers

6 Answers, 1 is accepted

Sort by
0
Accepted
Polya
Telerik team
answered on 16 Feb 2016, 11:47 AM
Hello Steve,

With the current implementation of RadTimeSpanPicker - all StepTimeSpanComponents (which includes the default components for day, hour, minute, second and millisecond) have minimum value of 0 for their Minimum and Maximum properties. That said when you set the Minimum to be less than 0 it will be processed as 0.
In order to achieve the desired you can create a custom TimeSpanComponentBase for each component you wish to use with negative values. Please find attached a sample project demonstrating this approach. In it I've created a NegativeHourTimeSpanComponent. In the overriden GetTicksFromItem() method I return correct ticks for the passed value, which can be a negative number as well.

As our built in implementation only works with positive numbers I would like to ask you to please share more information on your scenario and what caused the need for negative TimeSpan values.
If you think we should improve the implementation of our default components to also include negative numbers you can add a feature request in our feedback portal: http://feedback.telerik.com/Project/143

Regards,
Polya
Telerik
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
Steve
Top achievements
Rank 1
answered on 16 Feb 2016, 12:00 PM

Thanks Polya, that solution works great.

To elaborate on the situation, it was needed as part of a time tracking program, for users to add or remove time. I actually settled yesterday on a toggle between adding or removing time, along with a TimeSpanPicker showing only positive values, which works well for this specific situation, but I could also see a need for a negative value in a TimeSpanPicker if we were to use it for inline editing in a GridView, for example.

0
Karl
Top achievements
Rank 1
answered on 09 Nov 2018, 09:08 AM
I'm now using this to try and set TimeZone in a device for manually setting it up for a different country, but i'm needing negative in the hours column to be able to do this
0
Dinko | Tech Support Engineer
Telerik team
answered on 14 Nov 2018, 08:16 AM
Hello Karl,

The project provided by my colleague Polya demonstrate how you can add negative values in the Hours column. Can you elaborate more on if the approach in the project works for you or your case is different? 

Regards,
Dinko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Hans-Henrik
Top achievements
Rank 1
answered on 11 Oct 2019, 12:00 PM

I am working on an application where I use the GanttView.. here I have a property on my dependencies that holds the difference between owner and from task. This can be negative depending on the connection type.

I need to allow the user to edit this property, and even go from a positive timespan, to a negative timespan. Apparently the control does not support this? Or I can not see how this should be done at least..

0
Dinko | Tech Support Engineer
Telerik team
answered on 16 Oct 2019, 10:09 AM

Hi Hans-Henrik,

It seems that your question is related to RadGanttView control. I will ask that you open a new thread for the new questions you have as they are not related to the original topic. Thank you for understanding.

In case you use RadTimeSpanPicker control. Can you confirm that you have tried the approach (the attached project) suggested by my colleague Polya? If I have wrongly understood your scenario, may I ask you to elaborate more on your case? 

Regards,
Dinko
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
TimeSpanPicker
Asked by
Steve
Top achievements
Rank 1
Answers by
Polya
Telerik team
Steve
Top achievements
Rank 1
Karl
Top achievements
Rank 1
Dinko | Tech Support Engineer
Telerik team
Hans-Henrik
Top achievements
Rank 1
Share this question
or