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

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

3 Answers 55 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Christophe
Top achievements
Rank 1
Christophe asked on 16 Oct 2017, 12:24 PM

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.

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 17 Oct 2017, 06:49 AM
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.
0
Christophe
Top achievements
Rank 1
answered on 17 Oct 2017, 07:44 AM

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.

0
Accepted
Hristo
Telerik team
answered on 18 Oct 2017, 02:15 PM
Hi ,

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.
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Christophe
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Christophe
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or