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
6 Answers, 1 is accepted
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
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.
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?
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..
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?