User (Old forums)MemberJuly 16, 2008 at 8:12 pmPost count: 23064
I have 2 questions.
I wanted to display validation errors in a textbox (trying to emulate ValidationSummary in ASP.NET). However, I cannot figure out a way to access the messages without going through every cell in the grid. Is there an alternative method to do this?
Second Question :
I created a custom validationcriterion object that inherits from Xceed.Validation.ValidationCriterion
I set the validationlevel to Manual but it still always automatically validates. I do not have this problem with regular Constant and Datatype criterion when i set them to Manual. Here is the small test class i wrote that has this issue (DemoData is just a small class i used for binding):
Also, the instance of this criterion is only on column two (Str2 property of DemoData object) so it compares the new value going into Str2 and what is currently set in Str (column 1).
Private Class ValidateCrit
Public Overrides Function Clone() As Object
Return New ValidateCrit
Public Overrides Function Evaluate(ByVal validationProvider As Xceed.Validation.ValidationProvider, ByVal componentToValidate As Object, ByVal valueToValidate As String, ByRef validationMessage As String) As Boolean
Dim obj As Object = CType(componentToValidate, Xceed.Grid.DataCell).ParentRow
Dim demo As DemoData = CType(obj, Xceed.Grid.DataRow).SourceObject
If demo.Str & valueToValidate <> “12” Then
“Not equal to 12 (“ & demo.Str & valueToValidate & “)”
Imported from legacy forums. Posted by jdanko (had 1211 views)User (Old forums)MemberJuly 17, 2008 at 10:14 amPost count: 23064
I kind of figured out 2, but now have a different problem. I needed to override the CanEvaluate function and now it lets me at least leave the field and execute the validation by clicking the button. But, after clicking the button and executing the validation it marks the cell red and when I enter in a valid value and try to leave the cell it says its still invalid because it never fires the evaluate method again. It almost seems as though it needs to be automatic at that point. Basically, I want to ONLY execute the validation of the grid on click of a button. Not on leaving the cell.
I still haven’t found a way to do the validationsummary from my first question.
Imported from legacy forums. Posted by jdanko (had 513 views)User (Old forums)MemberJuly 17, 2008 at 6:10 pmPost count: 23064
Did you set the validation criterion using the validation provider on the cells of the datarow template?
For your last question you need to invoke the ValidationProvider.Validate() method to update the validation if you are using the manual mode.
You can choose when to invoke validation according to your needs.
If you want to invoke when the cell leaves, you can handle the Cell.LeavingEdit or any other event on the cell. Again you must do this on the DataRowTemplate of the grid so that all cells of the same type use your handlers.
Also you can look at the GridValidator sample located in your samples directory (i.e.: C:\Xceed Component Samples\Xceed Input Validator for .NET 1.2\Samples\Visual Basic .NET\GridValidator\ under Vista or C:\Program Files\Xceed ComponentsXceed Input Validator for .NET 1.2\Samples\Visual Basic .NET\GridValidator\ under XP) for info on how to setup and invoke validation on the grid programmatically.
Imported from legacy forums. Posted by Vincent (had 1346 views)User (Old forums)MemberJuly 18, 2008 at 3:50 pmPost count: 23064
I see what you are saying now. Since it is manual .Validate never gets fired unless I invoke, just like I did on the button click. So endingedit would be a good place to handle that. Yeah, I don’t believe the GridExample does exactly what i was wanting to do. I have looked over though. As far as the ValidationSummary goes can you think of any possible way to do this?
Thanks for the Info on my 2nd issue. It resolved my issue.
Imported from legacy forums. Posted by jdanko (had 654 views)User (Old forums)MemberJuly 21, 2008 at 10:30 amPost count: 23064
For the validation summary, it might be tricky to build a generic summary. I see that concatenating all generated error messages could be a summary if your configured description messages are short.
You could try to:
1) Build a list of all components and grid elements (cells) you want to summarize errors.
2) Analyse the content of its ErrorDescription properties by calling:
Errors = Errors + ValidationProvider.GetValidationError(component)
That being said it is a nice feature that Xceed could implement.
I will add that one to the list.
Imported from legacy forums. Posted by Vincent (had 1063 views)
- You must be logged in to reply to this topic.