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

TimeEditor

1 Answer 70 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
CY
Top achievements
Rank 1
CY asked on 22 Jun 2017, 12:45 PM
Is there anyway to disable certain hour and minutes from the editor when it is shown to user? Eg., I would like to make only 00, 15, 30 and 45 minutes available for selection. Can this be done at design time statically and runtime dynamically?

1 Answer, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 26 Jun 2017, 11:25 AM
Hi CY,

The Xamarin.Forms DataForm does not expose such functionality out of the box. We have a feature request logged to expose a mechanism to use a custom editor which you can track on the following link - DataForm: Implement Custom Editor

Apart from that you can check the documentation of the native controls and try to implement the functionality you are looking for by creating a custom renderer and modifying the native control. Here are the documentation for iOS and Android. The task is easily achievable in iOS by modifying the TKDataFormTimePickerEditor used:

[assembly: ExportRenderer(typeof(Telerik.XamarinForms.Input.RadDataForm), typeof(CustomTimeEditor))]
namespace TelerikXamarin.iOS.CustomRenderer
{
    class CustomTimeEditor : DataFormRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<RadDataForm> e)
        {
            base.OnElementChanged(e);
            this.Control.Delegate = new CustomDataFormDelegate();
        }
    }
    class CustomDataFormDelegate : TKDataFormDelegate
    {
        public override void SetupEditor(TKDataForm dataForm, TKDataFormEditor editor, TKEntityProperty property)
        {
            if (property.Name == "Time")
            {
                var datePickerEditor = editor as TKDataFormTimePickerEditor;
                datePickerEditor.DatePicker.MinuteInterval = 15;
            }
        }
         
    }
}


Regards,
Stefan Nenchev
Progress 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
Tags
DataForm
Asked by
CY
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Share this question
or