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

Custom validation with RIA Services and an MVVM solution

3 Answers 109 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Steve
Top achievements
Rank 1
Steve asked on 05 May 2011, 12:27 PM
Hi there.

I've seen the example for custom validation, but it doesn't seem to cater for an RIA services sort of solution.

I use a view model and have a DomainContext object (_context). I can call SubmitOperation on this to update my SQL database. If this fails based on not being able to update the relevant fields, the SubmitOperation returns an error.

Now what I want to do is somehow tie that SubmitOperation failure in with the custom validation on my GridView.

Any tips or suggestions would be appreciated.

3 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 06 May 2011, 09:26 AM
Hi John,

You may take a look at this blog post for more information about asynchronous validation via RIA services.
Let me know if this doesn't work for you.

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
Steve
Top achievements
Rank 1
answered on 06 May 2011, 10:38 AM
Hi there Nedyaiko.

Well I read through the post and I think it's useful, but it won't seem to work. I created CustomValidator.shared.cs in my web services directory in the same place as my domain service. I created it very similarly to how the blog showed it, but for some reason, it doesn't recognise 'using System.Web' as valid, and it thinks my domain service doesn't exist. The name spaces are the same, and if I try to create an instance of the class without that (i.e. MyProject.Web.Service.MyDomainService), the drop down intellisense after .Service only shows the validator and my domain context, not the service.

But even if this is solved (and I would like to get this solved), I'm not sure WHY this is needed since the [Key()] and [Required()] attributes are already in the web.gs UserName field. The Required attribute does trigger the 

BindingValidationError


event on the rad data grid. This is good. The Key one does not. It just causes the DomainContext.SubmitChanges function to return a failure. I just want to know how to tell it that I want that failure to update the UI, like Required one does. I appreciate that they work differently because Key has to check other items in the database, but still... how to make that update the UI in the same way as Required?
0
Nedyalko Nikolov
Telerik team
answered on 11 May 2011, 09:53 AM
Hi John,

In order to achieve such behavior you will need a special style for GridViewCell element. Let me clarify a little bit. There are two modes of validation - synchronous and asynchronous. The main difference between these modes is that "validation UI" should be shown from a different element. In the case of a "sync" validation GridViewCell is still in edit mode so GridViewEditorPresenter will show the "validation UI". In the case of "async" validation GridViewCell could be in "view" mode and there is no GridViewEditorPresenter element, so GridViewCell itself should show the "validation UI".
I hope this makes sense.

You can take a look at this forum thread for an idea how to customize GridViewCell style in order to show "validation UI" in "view" mode.

Greetings,
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
Steve
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Steve
Top achievements
Rank 1
Share this question
or