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

How to apply converter to sfDataform by code

Hello,
I need to use a converter in my editors. I found the instruction at https://help.syncfusion.com/xamarin/sfdataform/editing?cs-save-lang=1&cs-lang=csharp
It seems to meet my needs. How to apply the converter to the editor without declaring the property attribute?
Thank you

3 Replies

SP Subburaj Pandian Veluchamy Syncfusion Team July 31, 2019 12:03 PM UTC

Hi Tung, 
  
Thank you for contacting Syncfusion support. 
  
We have analyzed your query “Apply converter to property from code in DataForm”, as of now, DataForm supports converters from the attribute. While creatingDataFormItems we are getting converter from respective property attributes. 
  
Kindly share more information on your requirement not to use the converter in property attribute. It will be helpful for us to analyze further and provide you a better solution. 
  
Regards,
Subburaj Pandian V     



TU Tung August 1, 2019 01:13 AM UTC

Hello,

I cannot access the source code of the model because it is a third party *.dll.

Regards,


SP Subburaj Pandian Veluchamy Syncfusion Team August 1, 2019 12:36 PM UTC

Hi Tung, 
  
Thank you for the update. 
  
As mentioned in our previous update Converter need to give in property attribute. Your requirement can be achieved using CustomEditor in DataForm. In custom editor OnCommit override method you can convert your value and set it to property. Kindly refer our UG documentation to know more about custom editor in DataForm, 
  
  
Code Snippet: 
[C#]        
protected override void OnCommitValue(Entry view) 
{ 
     var dataFormItemView = view.Parent as DataFormItemView; 
     var value = Convert.ToInt32(view.Text); 
     view.Text = (value * 10).ToString(); 
     this.DataForm.ItemManager.SetValue(dataFormItemView.DataFormItem, view.Text); 
} 
  
We have prepared a simple sample for the same, 
 
Sample link: DataForm 
  
We hope this helps. Kindly revert us if you have any concern. 
 
Regards,
Subburaj Pandian V  
 


Loader.
Live Chat Icon For mobile
Up arrow icon