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

Disable validation on RadGridView

7 Answers 365 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Yossi Naar
Top achievements
Rank 1
Yossi Naar asked on 22 Mar 2010, 06:08 PM
Hi,
I have a data object that implements INotifyDataErrorInfo.
Unfortunately the support for this in RadGridView is still flaky and there are some visual problems so i am using my own custom style to control validations.

I turned off validation binding but this seems to only solve half my problem.
I now have the following problem - whenever i try to edit a cell that has validation errors i cannot leave the cell unless i press Esc.
Our application flow permits validation errors to exist so the user should not be forced to correct an error before they can move on to something else.

So my question is : how do i turn off editing validation? 

Thanks,
Yossi.

7 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 24 Mar 2010, 02:42 PM
Hi Yossi Naar,

Generally if you set "e.IsValid = false" within validating event this will cause RadGridView to return focus to the invalid cell. This is a desired behavior and we do not plan to change it.
However you can use CellValidating event just for a notification when edit is about to end. Within event handler you can mark cell (for example change background) as invalid, but also you have to set property or something like that of your view model which indicates that this data item is "dirty". After that you have to handle RowLoaded event and mark all invalid cells accordingly. The last step is required since cells will be recycled and reused when scrolled out of the view.

P.S. By the way RadGridView will support INotifyDataErrorInfo interface but only with versions for Silverlight 4, since this interface is not available for WPF.

Kind regards,
Nedyalko Nikolov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Yossi Naar
Top achievements
Rank 1
answered on 24 Mar 2010, 03:27 PM
Hi Nedyalko Nikolov ,

I think there was a misunderstanding here - i put down INotifyDataErrorInfo instead of IDataErrorInfo.
i am not monitoring  ANY events on the grid, including the CellValidating event.
What i have is a data object that implements IDataErrorInfo.

When this data object reports an error (through IDataErrorInfo) - the grid behaves in said manner (does not allow leaving cell unless esc is pressed).
This happens even if  DataMemberBinding does NOT include "ValidatesOnDataErrors=True"

To see that this is actually what happens you can try the code i posted on a different thread regarding IDataErrorInfo

I am not asking that you change the event binding behavior - this is how you choose this mechanism to behave and that's fine by me ( i also agree that it's a reasonable default behavior).
However, you are automatically using IDataErrorInfo if it is implemented by the data object - which is also fine, as long as i have some mechanism to turn off that support.

Thanks,
Yossi.





0
Nedyalko Nikolov
Telerik team
answered on 25 Mar 2010, 10:06 AM
Hi Yossi Naar,

We will consider your suggestion (request) as a part of our support for INotifyDataErrorInfo interface. We are doing our best to provide such support for the official version of SL 4.

Kind regards,
Nedyalko Nikolov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Yossi Naar
Top achievements
Rank 1
answered on 25 Mar 2010, 11:38 AM
Hi Nedyalko Nikolov,

I am sorry - but i kind of get the sense that you didn't really read my response.

Let me reiterate:
1. I a NOT using silverlight.
2. I meant to write IDataErrorInfo and instead i wrote INotifyDataErrorInfo
3. This is not a feature request - this is a question about how to change something that is working now.

If you have a data object that implements IDataErrorInfo , it is used by RadGridView - WPF RadGridView.
I am asking how to turn off that validation support when editing.

you can look at the link i added, there is a code example where this behavior occurs.

Thanks,
Yossi.


0
Nedyalko Nikolov
Telerik team
answered on 25 Mar 2010, 12:57 PM
Hello Yossi Naar,

RadGridView shares common code base for SL and WPF. So when we add support for the INotifyDataErrorInfo interface for the SL this will affect WPF version too. I'll try to clarify a little bit. This interface is designed to support asynchronous validation which means that a potentially invalid value should be stored until a notification (confirmation) that this value is incorrect arrives. When such notification arrives RadGridView should updates its UI accordingly (mark some cells as invalid).

I think that this is exactly what you want. As I said we will consider adding such functionality (asynchronous validation with an option to edit another cell even when there is already another invalid cell) for the WPF version as well. We are aware of your scenario requirements so we will do our best in order to fulfill them.

Regards,
Nedyalko Nikolov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Yossi Naar
Top achievements
Rank 1
answered on 25 Mar 2010, 01:10 PM
Hi Nedyalko Nikolov ,

I feel that i am running out of words..let me try this again:

RadGridView for WPF  currently supports IDataErrorInfo (see example i pointed to).
I don't want to Notify the grid of anything, i don't want INotifyDataErrorInfo support (well - it might be nice actually, but not for this current issue).

RadDataGrid actively binds and actively checks for a validation error in data objects that implement IDataErrorInfo (not INotifyDataErrorInfo).

What this means is that if you have an object that implements IDataErrorInfo as the target of the binding, the column will bind the editor for the cell to the dataobject, and will also* set the binding with "ValidateOnDataError = true".
What i want is to somehow control whether or not you set the "ValidateOnDataError" flag (or however it is you implemented it),



Thanks,
Yossi.




* -probably - don't know how you implemented, but this is an educated guess.

0
Nedyalko Nikolov
Telerik team
answered on 26 Mar 2010, 05:01 PM
Hello Yossi Naar,

Indeed your guess is right, RadGridView really creates binding for editing purposes with "ValidateOnDataError = true".

You can use one possible work around in order to meet your goals. The idea is simple, just create a custom column which inherits from GridViewDataColumn and change binding of the editing element accordingly. I'm attaching a sample project for a reference. For more information how to create custom column you can take a look at this blog post. Let me know how this works on your end.

Of course we'll try to add built-in support or more elegant solution for similar cases with some of our further releases.

Kind regards,
Nedyalko Nikolov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Yossi Naar
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Yossi Naar
Top achievements
Rank 1
Share this question
or