TimeEditor

2 posts, 0 answers
  1. CY
    CY avatar
    1 posts
    Member since:
    Sep 2012

    Posted 22 Jun Link to this post

    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?
  2. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    559 posts

    Posted 26 Jun Link to this post

    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
Back to Top