Tab key seems to not working properly

I am using the columncount parameter, i.e. set to 3. But when using tab key on keyboard, focus is not jumping over to entries in the other two columns. Do I need to set something different for a proper recognition of the tab key? 
And BTW: is it possible to set the focus to a certain entry field programmatically in code-behind?

3 Replies

VR Vigneshkumar Ramasamy Syncfusion Team July 17, 2018 12:32 PM UTC

Hi Gerhard,  
  
Thank you for contacting Syncfusion support.  
  
Query 1: Regarding Tab key and column count parameter   
  
  
As per SfDataForm control implementation, when SfDataForm is added in grid layout (Column count set) focus navigates to next row dataform field when TAB key is pressed. However, you can restrict the focus moved to next row field by using the override method MoveToNextFocusableEditor of class DataFormLayoutManager and return false to set the focus to the next Column field in SfDataForm to achieve your requirement.  
  
  
Please find the UG link for DataFormLayoutManager code example.  
  
   
Code snippet:  
  
      
    dataForm.LayoutManager = new DataFormLayoutManagerExt(dataForm);  
     
    public class DataFormLayoutManagerExt : DataFormLayoutManager  
    {  
        public DataFormLayoutManagerExt(SfDataForm dataForm) : base(dataForm)  
        {  
        }  
        protected override View GenerateViewForLabel(DataFormItem dataFormItem)  
        {  
            var view = base.GenerateViewForLabel(dataFormItem);  
            var textView = (view as Label);  
            textView.TextColor = Color.Blue;  
            return view;  
        }  
  
        public override bool MoveToNextFocusableEditor(DataFormItem dataFormItem)  
        {  
            return false;  
        }  
    }  
  
  
Query 2: Regarding query with set the focus to an editor field programmatically:  
   
You can achieve your requirement to set the Entry focus on form loading by changing the Control focus value of custom EntryRenderer by creating  the custom editor in SfDataForm by overriding the DataFormEditor class which is used to add new custom editor.  
   
Please find the below user guide link for adding custom editor in SfDataForm with example.  
   
Please find the code example for Xamarin cross platforms.  
   
Code snippet:  
   
   
UWP  
   
   private void Control_Loaded(object sender, RoutedEventArgs e)
        {
            Control.Focus(FocusState.Programmatic);
        }
   
   
Android  
  
private EditText NativeTextBox { get; set; }

        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);
            if (Control != null && Element is CustomEntry)
            {
                NativeTextBox = Control as EditText;
               
                if (e.NewElement != null && this.Control != null)
                {
                    ((CustomEntry)e.NewElement).PropertyChanging += EntryRenderer_PropertyChanging;
                    this.Control.ShowSoftInputOnFocus = true;
                }
            }   
   
   
  private void EntryRenderer_PropertyChanging(object sender, PropertyChangingEventArgs e)
        {
            NativeTextBox.RequestFocus();

  
        }   
  
   
ios  
   
 private UITextField NativeTextBox { get; set; }

        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);
            if (Control != null && Element is CustomEntry)
            {
                NativeTextBox = Control as UITextField;
                NativeTextBox.BecomeFirstResponder();
            }
        }
  
   
  
   
We have prepared a sample for both the queries. Kindly find the sample below,  
   
Sample:  DataFormCustomEntry
  
Please let us know if this is helpfull. 
 
Regards 
Vigneshkumar R 



GE Gerhard July 17, 2018 08:50 PM UTC

Hi Vigneshkumar, 

jumping to columns with tab key now works. Thanks a lot!

Kind regards,
Gerhard


VR Vigneshkumar Ramasamy Syncfusion Team July 18, 2018 04:39 AM UTC

Hi Gerhard,  
 
We are glad to know that your requirement has been achieved. Please get in touch if need further assistance on this.  
 
Regards 
Vigneshkumar R 


Loader.
Up arrow icon