Disabling adding a new row on Tab key

2 posts, 0 answers
  1. Mimi
    Mimi avatar
    7 posts
    Member since:
    Dec 2018

    Posted 24 Jan 2019 Link to this post

    Hello,

    I am trying to streamline a process using radGridView that allows users to tab through only the necessary controls on a form. When they hit the radGridView control, they're currently tabbing through all existing cells. This is desired - but when they leave the last cell of an existing cell, we want to disable the ability to add a new row. We don't want to them to have to add a new row unless they click on "Click here to add new row". 

    I've attached a screenshot of the behavior that I do not want. The yellow cells is from my conditional formatting. I'm not entirely sure what this row is because it doesn't have the default values that I've set when you click on "Click here to add new row".

    How can I disable this behavior?

    Thank you!

     

  2. Dimitar
    Admin
    Dimitar avatar
    2892 posts

    Posted 25 Jan 2019 Link to this post

    Hi Mimi,

    I have tested this with a new grid and if the user does not enter data no new row is added and the focus is moved to the next control (see attached). This is why I would suggest opening a new support ticket and attaching your project. This will allow us to properly investigate the case and provide you with a solution. 

    In general to customize the Tab behavior you need a custom GridNewRowBehavior which will allow you to override the method that processes this key. Here is an example:
    public RadForm1()
    {
        InitializeComponent();
      
        BaseGridBehavior gridBehavior = this.radGridView1.GridBehavior as BaseGridBehavior;
        gridBehavior.UnregisterBehavior(typeof(GridViewNewRowInfo));
        gridBehavior.RegisterBehavior(typeof(GridViewNewRowInfo), new CustoGridNewRowBehavior());
     
    }
     
    public class CustoGridNewRowBehavior : GridNewRowBehavior
    {
        protected override bool ProcessTabKey(KeyEventArgs keys)
        {
            return base.ProcessTabKey(keys);
        }
    }

    Should you have any other questions do not hesitate to ask.

    Regards,
    Dimitar
    Progress Telerik
    Get quickly onboard and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top