Error when Key-in only Year manually

4 posts, 0 answers
  1. Li
    Li avatar
    2 posts
    Member since:
    Aug 2013

    Posted 15 Aug 2013 Link to this post

    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;
          }
  2. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 16 Aug 2013 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Li
    Li avatar
    2 posts
    Member since:
    Aug 2013

    Posted 16 Aug 2013 Link to this post

    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.

  5. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 16 Aug 2013 Link to this post

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