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

Gridview validation affects button on my form

2 Answers 61 Views
GridView
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 27 Apr 2020, 04:24 PM
I have cell and row validation happening on my grid which works fine. But when I have a cell or row that has invalid data, it locks out all my buttons on the window and prohibits the user from clicking them. I suppose that is alright for my 'OK' and 'Apply' buttons because I don't want to submit bad data. But I also have a 'Cancel' button which just closes the form without saving anything. I want that button always enabled even if the GridView is not valid.

2 Answers, 1 is accepted

Sort by
0
Accepted
Vladimir Stoyanov
Telerik team
answered on 30 Apr 2020, 02:07 PM

Hello John,

This behavior comes from RadGridView's validation nature. Basically, if there is an invalid value in any cell, the gridview is stealing the focus in order to prevent any invalid data to get committed. This is why nothing outside of RadGridView can be clicked.

There is a feature request to introduce an API that allows you to change this behavior. You can find it logged in our feedback portal.

To avoid this behavior you can subscribe to the GotFocus event of the control that you want to get the focus (in your case the Cancel button) and call the CancelEdit() method of RadGridView.

private void CancelButton_GotFocus(object sender, RoutedEventArgs e)
{
    this.radgridView.CancelEdit();
}

On a side note, you can also take a look at the Cancel Edit On LostFocus article.

I hope you find this helpful. 

Regards,
Vladimir Stoyanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
John
Top achievements
Rank 1
answered on 30 Apr 2020, 03:22 PM
Thank you kind sir
Tags
GridView
Asked by
John
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
John
Top achievements
Rank 1
Share this question
or