Binding SfComboBox.SelectedValue does NOT populate SfComboBox.Text

If you populate an SfComboBop as per documentation in https://help.syncfusion.com/xamarin/sfcombobox/populating-data, supplying a DataSource model with separate columns for Value & DisplayName, this providing SelectedValuePath (=Id) and DisplayMemberPath (=DisplayName) the ComboBox does NOT display any text until a user selects a new value from the list.

This is common scenario where a form aims to display current data values, and the current version of the comboBox will display blanks, even though SfComboBox.SelectedValue IS populated.

Note: it does work if you bind to a corresponding SelectedItem, rather than SelectedValue, but this is a PIA.

Please advise.
Thanks,
Phil

6 Replies

PA Paul Anderson S Syncfusion Team September 19, 2018 01:02 PM UTC

Hi Phil, 
 
Greetings from Syncfusion. 
 
In AutoComplete control, we can populate any custom object and the DisplayMemberPath can be set to display the desired property[Name] of the custom object in the suggestion box. The SelectedValuePath property is used to retrieve the value of the selected item in the dropdown when selected. The SelectedValue property will get updated based on the selection and for loading the default values in the control we should use only the SelectedItem, but SelectedValue is for retrieving the value of our desired property[ID] based on the selection. 
 
We have scenarios where SelectedValue can have duplicate items when other than ID say DisplayMemberPath will be loaded with Countries and SelectedValue will be binded to Continent which will be the same for many countries. So, in that case we cannot populate based on SelectedValue. 
 
Please let us know if you have any concerns. 
 
Regards, 
Paul Anderson 



PH Phil Holmes September 20, 2018 12:09 AM UTC

Hi Paul, thanks for your reply, which in isolation, does make sense. They key part of your point is the assumption that the Value part of the row source dataset is not unique. This is possible, but rare, and even in that case, it would be logical to return any or 1st of corresponding values.

The real issue here though I would argue is that when you present a control, you almost always want to prepopulate it existing (data bound) values. Every data form works like this. You support SelectedValuePath and DisplayMemberPath, which is great, and usually standard functionality. All your users are going to have to implement extra lookup code to either populate SfComboBox.Text, or generate another item model to populate SelectedItem, rather than the normal practice of just setting the SelectedValue.

I suggest it would be better to implement as most do, and just display 1st or any of corresponding values, in which case you will cover the 90% usage scenario, which is that the rowsouce is a unique dataset.

Thanks,
Phil


PA Paul Anderson S Syncfusion Team September 20, 2018 08:57 AM UTC

Hi Phil, 
 
Thanks for giving valuable suggestion. 
 
We are considered your requirement as a feature for our SfComboBox control and have logged a feature report for this requirement. We will analyze the feature with our SfComboBox source implementation for the possibility with the existing behavior and will be available in any of our upcoming release. 
 
Regards, 
Paul Anderson 



OL oladayo June 28, 2019 05:02 PM UTC

The SelectedValue only have a get prop. but doesnt contain the set prop...and i need to bind the selected value to the value selected before....please a need a solution to that..God bless you 


PH Phil Holmes June 28, 2019 11:56 PM UTC

Hi, you need to set SelectedItem, not SelectedValue. If you are binding the row source to an set of entities, just look up the desired Item, using whatever key value you have, then set SelectedItem to that entity value.



MK Muneesh Kumar G Syncfusion Team July 1, 2019 09:14 AM UTC

Hi oladayo, 
 
We would like to let you know that you can achieve your requirement by setting SelectedItem in SfComboBox. Please refer below user documentation for more details about that.  
 
 
Regards, 
Muneesh Kumar G. 


Loader.
Up arrow icon