Hello,
We have a datagrid that won't show validation when the datagrid property ValidatesOnDataErrors is set to "InViewMode", when we set the property to "InEditMode" we get validation, but then we can't leave the cell.
The code bellow shows how we have set the datamemberbinding of the column
DataMemberBinding=
"{Binding ClientDocument.Name, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnNotifyDataErrors=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"
The name property looks like the following code
[Required(AllowEmptyStrings=
false
,ErrorMessageResourceType =
typeof
(ValidationResources), ErrorMessageResourceName =
"NameRequiredErrorMessage"
)]
public
string
Name
{
get
{
return
this
.NameField;
}
set
{
this
.RaiseDataMemberChanging(
"Name"
);
this
.ValidateProperty(
"Name"
, value);
if
(Name != value)
{
this
.NameField = value;
this
.RaisePropertyChanged(
"Name"
);
this
.RaiseDataMemberChanged(
"Name"
);
}
}
}
The Name property is a member of a class that exists only on the client. (No RIA Services involved). The class ClientDocument inherits from Entity.
Thanks,
Sodi We
15 Answers, 1 is accepted
I suppose that there is only a red rectangle around the failed cell and the error message is not shown, is that the problem?
You can subscribe to the CellValidating event, perform your validation logic there and set the e.ErrorMessage to the text you want to show to the user.
Let me know if I am missing something.
Best wishes,
Veselin Vasilev
the Telerik team
When the property ValidatesOnDataErrors is set to "InEditMode" there is a red rectangle and I also see the error message but when I set the property to "InViewMode" I don't see the red rectangle or the error message.
Thanks,
Sodi We
This is by design. That property instructs the RadGridView to validate the data only in view mode - e.g. when the grid is shown. This will disable the validation in Edit mode.
So, you might not want to leave that property to InViewMode only.
Greetings,
Veselin Vasilev
the Telerik team
I've created a support ticket (368689) with a little test project to demonstrate my case.
Test project: http://www.telerik.com/ClientsFiles/232106_testproject.zip
I hope this helps solving this issue for me,
Thanks again,
Sodi We
I have already replied to your forum post:
Thank you for the provided project.
What is the ultimate goal you want to achieve when the ValidatesOnDataErrors is InEditMode or Default?
Do you want to just have the other controls on the page working (currently they are locked) if one of the gridview cells is in invalid state? If so, please set the ActionOnLostFocus="None" property of RadGridView.
Let me know if this helps.
Kind regards,
Veselin Vasilev
the Telerik team
Our goal is to set ValidatesOnDataErrors to InViewMode and still show the validationtooltip (when the grid edit has been committed). In our sample application, you can see that this is not the case when we're working with subproperties, but only with properties directly.
Our ultimate goal is thus to show validation to the user when the grid is in viewmode.
Thank you,
Sodi We
We are indeed using the ActionOnLostFocus=None. This is because all our pages have a save button and an add button. If we set the ActionOnLostFocus to Commit, then we have to click the save/add button twice when we're editing an item in the grid: once to end the edit, and once again to execute the command bound with the save/add button.
Maybe there is a way to get past this?
Thanks,
Sodi We
The problem is fixed in our Q3 2010 version. Now if you edit a cell and click on a button - the cell goes off edit mode and the button click event is executed.
Please try it out.
Sincerely yours,
Veselin Vasilev
the Telerik team
Excuse me for the delayed reply. Unfortunately, the Q3 release did not solve this issue. Could it be that the button click event is indeed fired, but not the command? I would like the grid as soon as a button is clicked, to be commited AND allow the command to be executed.
Thank you for your feedback,
Sodi We
Could you provide me with some more info about your scenario, since all issues related to buttons out RadGridView are solved with 2010.Q3 release?
You've post another problem with ValidatesOnDataErrors property when complex property should be validated. We resolved this issue and the fix will be available with the next latest internal build (every Monday night).
Nedyalko Nikolov
the Telerik team
We have a RadToolBar with some buttons in it. These buttons are RadButtons. One of these buttons adds a new item to the grid via the click event. When adding the first item everything goes as expected. But to add a new item while the first item has validation errors, I still have to click twice: once to commit the grid and once to actually add a new item (= click event).
I've investigated this further and found that when the selectedCELL is the one causing the validation errors to occur, this will make the user to click twice before the click event is executed.
For example: I have a grid with items bound to it with a string field and a boolean field. There is validation on the string field: it cannot be empty. When the user click add item for the first time, the textbox in the new line in the grid gets the focus. If the user doesn't want to fill in any data but immediately add some more rows and clicks add new item again, no new line is added. The user has to click again to add a new line in the grid. It's even so that any data entered in a new line after the first add new item click and before the second add new item click is lost.
If the selected cell is the checkbox cell, and the user clicks add new item a few times in a row, all items have been added to the grid without forcing the user to click twice for every new item.
I hope this issue is a little bit more clear to you so that it can be solved :-)
Kind regards,
We
I've tried to simulate the reported issue unfortunately to no avail. I'm attaching my sample project which works fine on my end. Could you please tell me what to do in order to reproduce the problem? Thank you in advance.
Best wishes,Nedyalko Nikolov
the Telerik team
All you need is asynchronous validation. For more information you could check this blog post. I'm attaching a modified version of the example with some interface implementations within Person class (INotifyDataErrorInfo, IEditableObject and INotifyPropertyChanged) as another example how to implement async validation.
Let me know how it works on your end.
Nedyalko Nikolov
the Telerik team