Add a button to a DataFormTextItem

Hi,

how do I create a customeditor to a sfdataform with an entry and a button. I need a DataFormTextItem with a "Search Button".

Regards,
Diego


1 Reply 1 reply marked as answer

SS SaiGanesh Sakthivel Syncfusion Team May 17, 2021 11:58 AM UTC

Hi Diego, 
 
Thank you for contacting syncfusion support. 
 
#Regarding CustomEditor in DataForm. 
We have checked the reported query from our end. We would like to inform you that you can achieve your requirements by creating the custom editor by overriding the DataFormEditor class. Please refer to the following code snippet for your reference. 
 
Code snippet 
dataForm.RegisterEditor("CustomEditor", new CustomTextEditor(dataForm)); 
dataForm.RegisterEditor("Name", "CustomEditor"); 
 
 
 
public class CustomTextEditor : DataFormEditor<StackLayout> 
{ 
    SfDataForm sfDataForm; 
            public CustomTextEditor(SfDataForm dataForm) : base(dataForm) 
            { 
            } 
            protected override StackLayout OnCreateEditorView(DataFormItem dataFormItem) 
            { 
                        return new StackLayout(); 
            } 
            protected override void OnInitializeView(DataFormItem dataFormItem, StackLayout view) 
            { 
                        base.OnInitializeView(dataFormItem, view); 
                        view.Orientation = StackOrientation.Horizontal; 
                        var entry = new Entry(); 
                        entry.HorizontalOptions = LayoutOptions.FillAndExpand; 
                        var button = new Button(); 
                        button.HorizontalOptions = LayoutOptions.End; 
                        view.Children.Add(entry); 
                        button.Text = "Search"; 
                        view.Children.Add(button); 
            } 
} 
 
Please refer to the tested sample in the following location. 
 
Please refer to the following UG Documentation link about ‘How to create a CustomEditor in a SfDataForm’. 
 
 
Please let us know if you have any concern. 
 
Regards,
SaiGanesh Sakthivel


Marked as answer
Loader.
Up arrow icon