This is a migrated thread and some comments may be shown as answers.

Disabling adding a new row on Tab key

1 Answer 195 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mimi
Top achievements
Rank 1
Mimi asked on 24 Jan 2019, 10:46 PM

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!

 

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 25 Jan 2019, 09:36 AM
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.
Tags
GridView
Asked by
Mimi
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or