TKDataFormDatePickerEditor Null Date

2 posts, 0 answers
  1. jon
    jon avatar
    24 posts
    Member since:
    Jun 2009

    Posted 31 Jan Link to this post

    I'm trying to make a TKDataFormDatePickerEditor to load with an empty date field but the TKDataFormDatePickerEditor always shows today date. Here's what I'm doing in the UpdateEditor method after setting the value candidate to null.
    if (property.Name == "StartDate") {
      if (this.ownerVC.dataSource ["StartDate"].ValueCandidate == null) {
        ((TKDataFormDatePickerEditor)editor).EditorValueLabel.Text = string.Empty;
      }
    }
  2. Adrian
    Admin
    Adrian avatar
    167 posts

    Posted 03 Feb Link to this post

    Hello, Jon,

    Thank you for contacting us.

    To show an empty string as text to the editor value label when the value candidate is null you should use the hintText property of TKEntityProperty. Consider the code snippet:
    public override void ViewDidLoad ()
    {
        base.ViewDidLoad ();
        //..
        this.dataSource ["DateOfBirth"].HintText = string.Empty;
        //..
    }

    Another option is to implement SetupEditor method and use the Placeholder property of TKDataFormDatePickerEditor:
    public override void SetupEditor (TKDataForm dataForm, TKDataFormEditor editor, TKEntityProperty property)
    {
        if (property.Name == "DateOfBirth") {
            ((TKDataFormDatePickerEditor)editor).Placeholder = string.Empty;
        }
    }

    I hope this helps. If you have further questions, feel free to contact us again.

    Regards,
    Adrian
    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
  3. DevCraft banner
Back to Top