We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

SfAutoComplete custom editor inside SfDataForm

Hi guys followed these steps to create custom editor for my SfDataForm.
https://help.syncfusion.com/xamarin/sfdataform/editing#creating-new-custom-editor
When my SfDataForm is bound however the value in my business object (model) is not being set inside the entry control inside the SfDataForm. I need to set the Text of the Entry control when the data form is bound.

5 Replies

SP Subburaj Pandian Veluchamy Syncfusion Team April 12, 2019 01:13 PM UTC

Hi Mario, 
  
Thank you for contacting Syncfusion support. 
  
We have analyzed the reported query “The custom editor value doesn’t updated on initial load when set the value in model class”, to update the value for custom editor in model class, you must override the OnUpdateValue method of your custom editor class and call this method from initializeview method to update the value to the view. 
  
Please refer the following code, 
 
public class CustomEditor : DataFormEditor<SfAutoComplete> 
    { 
        public CustomEditor(SfDataForm dataForm): base(dataForm) 
        { 
  
        } 
 
        protected override SfAutoComplete OnCreateEditorView(DataFormItem dataFormItem) 
        { 
            return new SfAutoComplete(); 
        } 
  
        protected override void OnInitializeView(DataFormItem dataFormItem, SfAutoComplete view) 
        { 
            base.OnInitializeView(dataFormItem, view); 
            this.OnUpdateValue(dataFormItem, view); 
        } 
  
        protected override void OnUpdateValue(DataFormItem dataFormItem, SfAutoComplete view) 
        { 
            var cellvalue = this.DataForm.ItemManager.GetValue(dataFormItem); 
            if (cellvalue != null && view.Text == cellvalue.ToString()) 
                return; 
            view.Text = cellvalue == null ? string.Empty : cellvalue.ToString(); 
        } 
    } 
 
We have attached sample for your reference,
 
 
Sample link: DataForm 
  
Note: We have implemented this OnUpdateValue override method in our 2019 Volume 1 Release update version 17.1.0.38, kindly use this or latest update version to achieve your requirement. 
  
We hope that this helps. Kindly revert us if you have any concern. 
 
Regards,
Subburaj Pandian V
 



MA Mario April 12, 2019 07:52 PM UTC

In the AutoComplete inside the SfDataForm when the user clicks the X button. How can I capture this event?


BK Bharathiraja K Syncfusion Team April 15, 2019 12:35 PM UTC

Hi Mario, 
 
We have checked your requirement from our side and in our current implementation, we do not have event for tracking the Close Button action in SfAutoComplete. We have logged a feature report for the same. You can find the feedback link details from below.  
  
  
Please cast your vote to make it count. We will prioritize the features every release based on the demands.  
   
If you have any more specification/suggestions to the feature request, you can add it as a comment in the portal.  
 
Regards, 
Bharathi. 



MA Mario April 15, 2019 12:43 PM UTC

Ok so how can I tell the autocomplete value turned empty?


BK Bharathiraja K Syncfusion Team April 16, 2019 06:08 AM UTC

Hi Mario, 
 
We have checked the workaround to achieve your requirement in SfAutoComplete control. We can get the text length using ValueChanged Event. Please find the code snippet for your reference, 
 
Code Snippet [C#]:  
 void Handle_ValueChanged(object sender, Syncfusion.SfAutoComplete.XForms.ValueChangedEventArgs e)
        {
            if ((sender as SfAutoComplete).Text.Length == 0)
            {
                DisplayAlert("Items are empty", "Select an item", "Cancel");
            }
        }
 
 
 Sample Link : http://www.syncfusion.com/downloads/support/directtrac/general/ze/AutoComplete_143959840354946

Please check with the sample and let us know, if you have any concern.
 
 
Regards, 
Bharathi. 


Loader.
Live Chat Icon For mobile
Up arrow icon