Null values for pickers

4 posts, 1 answers
  1. Simon
    Simon avatar
    11 posts
    Member since:
    Mar 2020

    Posted 24 Mar Link to this post

    I have a number of fields in my class that are nullable but I am using a TKDataFormPickerViewEditor (Date does the same)  and when i load a new object in the form it always sets the nullable fields to being the first one in the picker list. I assumed that I could set the SelectedIndex = -1 but that does nothing.
  2. Simon
    Simon avatar
    11 posts
    Member since:
    Mar 2020

    Posted 24 Mar in reply to Simon Link to this post

    Probably should say this is in a Xamarin forms project
  3. Answer
    Yana
    Admin
    Yana avatar
    5002 posts

    Posted 25 Mar Link to this post

    Hello Simon,

    First, I will start with the TKDataFormPickerViewEditor  - it uses the iOS UIPickerView as its editor.  The UIPickerVIew control does not provide the option to have no selection - always one of the items should be selected. The selection propagates to the DataForm property.

    I have attached a sample that shows how you can partially achieve the behavior by creating a custom renderer of the iOS platform. In short, you can change the initial value of the editor label, still, as soon as the picker is shown, the property value will be updated. Please have a look at the implementation and consider whether this approach would work for you.

    As to the Date/Time pickers - we have a feature request regarding support for null value, you can cast your vote and track its status at the link below:

    DataForm: [iOS] Consider improvements for null value support for date/time values

    I am looking forward to your reply.

    Regards,
    Yana
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
  4. Simon
    Simon avatar
    11 posts
    Member since:
    Mar 2020

    Posted 25 Mar in reply to Yana Link to this post

    Thanks that does give a reasonable solution
Back to Top