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

Error when Key-in only Year manually

3 Answers 62 Views
DatePicker
This is a migrated thread and some comments may be shown as answers.
Li
Top achievements
Rank 1
Li asked on 15 Aug 2013, 10:04 AM
Hi Guys,

I'm trying to implement my own date filter which only based on Year, and the following code works when you using
a canlendar to pick the year number, it can shows 2013 when you pick it.

However if you enter year number from textbox, the tooltip will display error, and after invistigation, I found
if I enter 1920 into textbox, it will read first two digis and parse it as 19-08-2013, and when the 3rd digit
entered, it shows a error.

How can I input year number manually?

Thanks.


public
override FrameworkElement CreateFieldFilterEditor()
      {
          Telerik.Windows.Controls.RadDatePicker datePicker = new Telerik.Windows.Controls.RadDatePicker();
          datePicker.DateSelectionMode = Telerik.Windows.Controls.Calendar.DateSelectionMode.Year;
          datePicker.Culture = new System.Globalization.CultureInfo("en-US");
          datePicker.Culture.DateTimeFormat.ShortDatePattern = "yyyy";
           //dateTimePicker.InputMode = Telerik.Windows.Controls.InputMode.DatePicker;
          // This binding will transfer the significant property of your editor to the filtering view model.
          Binding selectedValueBinding = new Binding("Value");
          selectedValueBinding.Mode = BindingMode.TwoWay;
          selectedValueBinding.FallbackValue = null;
          selectedValueBinding.Converter = new DateTimeFilterEditorConverter();
          datePicker.SetBinding(Telerik.Windows.Controls.RadDatePicker.SelectedValueProperty, selectedValueBinding);
          return datePicker;
      }

3 Answers, 1 is accepted

Sort by
0
Vladi
Telerik team
answered on 16 Aug 2013, 07:33 AM
Hi,

Unfortunately in the current version of RadDatePicker control it is not possible to achieve only year input. We are currently improving the parsing of the control and in our next official release of RadControls the described approach will be available. In the next official release it will be possible to set the ShortDatePattern = "yyyy" and when the input is "1920" it will be parsed to the year 1920.

Regards,
Vladi
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Li
Top achievements
Rank 1
answered on 16 Aug 2013, 08:01 AM
Hi Vladi,

Thanks for the response... if that's the case I may have to disable user input and provide only popup selection for the this speicific scenario. I'll talk to Shanan first.

Thanks.

0
Vladi
Telerik team
answered on 16 Aug 2013, 10:19 AM
Hello,

You can take a look at our ReadonlyInputField example in our SDK repository here which shows a possible approach of making the input field of the DateTimePicker/DatePicker controls read-only. With this approach only the popup could be used to select a date in the control. You can download the entire repository directly from this link.

Hope this is helpful.

Regards,
Vladi
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
DatePicker
Asked by
Li
Top achievements
Rank 1
Answers by
Vladi
Telerik team
Li
Top achievements
Rank 1
Share this question
or