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

Validation and CellEditEnded

6 Answers 238 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Terry Foster
Top achievements
Rank 1
Terry Foster asked on 12 Jan 2010, 08:05 PM
Hi,

Here is what I need to do.  I'm binding (two-way) to a list of objects.  Whenever the user changes a cell value, I'd like to immediately save the change.  Invalid (e.g., out of range) values are tested by the property setters on my objects and an exception is thrown when invalid.  The grid handles this well by not allowing the user to leave the cell until it has a valid value.  I manage the saving part by handling the CellEditEnded event.  I check to see if the OldData is different from the NewData and, if so, I go ahead and save (a visibly lengthy process reflected with a 'waiting' indicator).

The issue I have is that when my property throws an exception due to an invalid value, the CellEditEnded event is still raised despite the fact that the cell remains in edit mode until the user corrects the value.  I found this to be very strange, but it wouldn't be that big of a deal if had a way to determine that the editing is currently invalid, which I can't seem to find.

So my questions are:

1) Is there a better way to do any of this?
2) How can I determine in my CellEditEnded event handler that the cell is not valid so as not to bother trying to save it?

Thanks,
Terry

6 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 14 Jan 2010, 01:27 PM
Hi Terry Foster,

Indeed this is very strange behavior. I've just tested our latest official release (2009.Q3.SP1 aka 2009.3.1208) and I was unable to simulate the issue.
Can you reproduce this with our latest release? If so I'll need some more information about your scenario such as type of the data source, how you get data and any information you may find useful.


Best wishes,
Nedyalko Nikolov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Terry Foster
Top achievements
Rank 1
answered on 15 Jan 2010, 03:04 PM
Here is some additional information based on some things I've recently learned.  We are using DevForce for our business objects which uses its own validation framework.  So I end up with two situations:

1) Custom (hand-written) properties where I manually validate values in the setters and throw an exception when not valid.
2) Auto-generated BO properties with DevForce-implemented validation attributes.

For each scenario, I'm seeing different behavior in the grid when I enter an invalid value.  Specifically:

1) The cell stays in edit mode, is outlined in red, a red popup displays my exception message, and the CellEditEnded event is NOT raised.  (This is the behavior I desire and would expect.)
2) The cell stays in edit mode, but the whole row is highlighted red, a standard tooltip displays my exception message, and the CellEditEnded event IS raised.

I simply do not understand why the second scenario is happening.  Obviously, an exception being thrown when the bound property is being set to the invalid value, but the grid seems to be handling it significantly differently.  Do you have any ideas?  I would think that you would at least be able to tell me what circumstances would cause the grid to highlight the whole row red instead of just the offending cell.

Thanks,
Terry
0
Nedyalko Nikolov
Telerik team
answered on 19 Jan 2010, 10:24 AM
Hello Terry Foster,

The only reason GridViewRow to become red (invalid) is that RowValidation is not passed. There are two validation layers UI and data layer. In order to validate the UI layer you have to handle RadGridView.RowValidating event. If not so probably some binding error (exception) is raised when BO is about to be committed. You can hook for the RadGridView.RowValidated event (Data layer validation) and check the event args. The associated GridViewRow will enter into invalid state if there are some validation results (e.ValidationResults.Count > 0).

Kind regards,
Nedyalko Nikolov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ward
Top achievements
Rank 1
answered on 02 Aug 2010, 07:30 PM
Hi Terry - I'm writing from IdeaBlade DevForce. I confess to ignorance of the details of the Telerik grid. The guidance given here would seem to provide you with some direction.

We cannot become experts in every vendor's controls. But we are eager to ensure the best possible experience when Telerik and DevForce come together.
 
Nedyalko wrote: "In order to validate the UI layer you have to handle RadGridView.RowValidating event. If not so probably some binding error (exception) is raised when BO is about to be committed."

As I read this, you may be responsible for doing something in the UI beyond merely binding to your DevForce entity. If you discover that we are throwing an exception in the binding ... then something is amiss either with us or with the way you wrote a custom validator (e.g., your custom validator itself is throwing an exception).

If Nedyalko's advice works out, please let us know so we can share your findings with others. If it does not because we're doing something wrong ... or if you think we should be doing something else to improve the experience, please let us know as well.

Either way, you can initiate action with a post to our forum: http://www.ideablade.com/forum/default.asp

Everyone benefits when we're all on the same page.
0
Iosu Buenetxea
Top achievements
Rank 1
answered on 02 Aug 2010, 08:28 PM
Ward

We have post a support ticket on ideablade support..

check #7317

Thanks

Iosu
0
Ward
Top achievements
Rank 1
answered on 05 Aug 2010, 10:42 PM
In case someone is wondering and missed the post on our forum, we were unable to reproduce the problem even when given a sample that claimed to reveal it. Perhaps there is something undisclosed in coding of the customer's object model. 

For the nonce, there does not appear to be a defect in either Telerik or DevForce. Below is our report.
--

We have not been able to duplicate the issue.

 

  1. We have adjusted the sample sent by the customer to use NorthwindIB.  We also added a CellEditEnded EventHandler to the sample.
  2. We have tested both with/without DevForce Validation. (We switched between Validation modes using the EF Model Designer properties).
  3. The CellEditEnded event is NOT fired when there is a validation error. (As expected).

 

Note: The CellEditEnded Event IS FIRED when leaving the grid (to see this in action hit esc) so it is important to test in the handler for changes. (This is not a DevForce related behavior).

 

Perhaps there is some further specific behavior that was not outlined in the sample? If so please add an illustration to the sample and return to us.

Tags
GridView
Asked by
Terry Foster
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Terry Foster
Top achievements
Rank 1
Ward
Top achievements
Rank 1
Iosu Buenetxea
Top achievements
Rank 1
Share this question
or