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

Null values for pickers

3 Answers 29 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Veteran
Simon asked on 24 Mar 2020, 11:03 AM
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.

3 Answers, 1 is accepted

Sort by
0
Simon
Top achievements
Rank 1
Veteran
answered on 24 Mar 2020, 11:30 AM
Probably should say this is in a Xamarin forms project
0
Accepted
Yana
Telerik team
answered on 25 Mar 2020, 03:48 PM

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.
0
Simon
Top achievements
Rank 1
Veteran
answered on 25 Mar 2020, 04:51 PM
Thanks that does give a reasonable solution
Tags
DataForm
Asked by
Simon
Top achievements
Rank 1
Veteran
Answers by
Simon
Top achievements
Rank 1
Veteran
Yana
Telerik team
Share this question
or