radDatePicker get the date of the current week with the nameday ?

4 posts, 1 answers
  1. Christophe
    Christophe avatar
    4 posts
    Member since:
    Oct 2016

    Posted 16 Oct Link to this post

    Hello all,

    I'm looking for an option that allow to get the date of the current week with an input by the start of the nameday.

    example : 

    we are the 16 oct

    I write on the keyboard 'f'

    I wish an autocompletion with 'friday 20 october'

    this is possible ?

    with Tuesday and Thursday 2 keypress are required.(tu or th)

    Thanks.

  2. Dimitar
    Admin
    Dimitar avatar
    1994 posts

    Posted 17 Oct Link to this post

    Hi Christophe,

    We do not have such functionality out of the box but you can create it using the FreeFormDateTimeProvider. For example, you can use the ParsingDateTime event in order to check the input string and return the desired value:
    public RadForm1()
    {
        InitializeComponent();
        this.radDateTimePicker1.MaskProviderCreated += RadDateTimePicker1_MaskProviderCreated;
        this.radDateTimePicker1.DateTimePickerElement.TextBoxElement.MaskType = MaskType.FreeFormDateTime;
    }
     
    private void RadDateTimePicker1_MaskProviderCreated(object sender, EventArgs e)
    {
        var provider = this.radDateTimePicker1.DateTimePickerElement.TextBoxElement.Provider as FreeFormDateTimeProvider;
        provider.ParsingDateTime += Provider_ParsingDateTime;
    }
     
    private void Provider_ParsingDateTime(object sender, ParsingDateTimeEventArgs e)
    {
        if (e.InputString == "f")
        {
            e.Result = DateTime.Today.AddDays(-(int)(DateTime.Today.DayOfWeek - DayOfWeek.Friday));
        }
         
    }

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Christophe
    Christophe avatar
    4 posts
    Member since:
    Oct 2016

    Posted 17 Oct Link to this post

    Hello Dimitar,

    Thank you for your answer.

    It almost works. However I lost the suggestion(autocomplete) when I write the letter of the day

    Do you have any ideas ? I'm looking for an option in the documentation

    Best regards.

  4. Answer
    Hristo
    Admin
    Hristo avatar
    1087 posts

    Posted 18 Oct Link to this post

    Hi Chriostophe,

    Thank you for writing.

    The FreeFormDateTimeProvider is not performing autocomplete or suggest and this is a desired behavior. The built-in date parsing mechanism is rather complex and it is using formal grammar theory to create tokens and to translate the input into a meaningful date. You can also check the following blog post providing detailed information on how the free form date provider is working internally: https://www.telerik.com/blogs/radinput-2-0-and-date-parsing-where-compiler-theory-meets-user-needs

    I hope this information is useful. Please let me know if you have other questions.

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top