Both the CellFormatting event is called, but apparently the RowValidating event isn't and neither is the CellEndEdit event. However, the DataTable that the grid is bound to is updated properly. For the time being, what I'm doing is rebinding the DataTable to the grid. This works in some cases, but I end up doing my validation after the data has been saved into the DataTable, and by that point it's too late and messes up my data.
Is there a way for me to manually fire the Validation code? I don't see an easy way to force it to be called in a way that is going to intercept something like this because it seems to bypass all of my validation code.
17 Answers, 1 is accepted
Thank you for writing.
I managed to reproduce the described issue with the RowValidating event. We will investigate this further and address it in one of the feature releases. Currently, you can try to use the CellValidating event instead. Please excuse us for the inconvenience.
I have updated your Telerik points for the report.
Do not hesitate to contact me again if you have any additional questions.
All the best,
Martin Vasilev
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.
1. I save the current row index.
2. I either move next or move previous in my binding source, depending on whether or not I'm on the first row. This will cause the cell and row validation events to fire. If my grid has only one row, I don't know how to get the validation events to fire because there is no previous or next row to move to. In this unlikely scenario, I won't save the changed record.
3. If the validation fails, I ask the user whether they want to fix the row before closing. If they do, I set cancel to true both for the row validation and the form close. Otherwise, they can just close without saving.
4. If they want to fix the error, I reset the position of my binding source to the saved row index and don't close the form.
Thank you for sharing your work-around. We are aware of RowValidating issues and we are going to improve this functionality in future. Write us back if you have any other additional questions.
All the best,
Martin Vasilev
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Hallo,
I have come across the same problem that the RowValidating event does not fire.
Your suggestion to use The CellValidating event cannot be a substitute for the RowValidating event.
For Example, in these cases I must validate cells when the user finishes to enter the whole data into a record:
1. Comparing two cells (check if one date greater than other)
2. Check for required fields.
The issue is very urgent.
Do you have a better solution, or is the bug going to be solved in the close future?
Thanks,
Kr,Kr,
Thank you for writing.
Unfortunately, there is not a very clean work-around for the RowValidating issues. Currently, we are working on a major RadGridView revision, which will bring a lot of improvements and new features including validating scenarios. Our plans are to introduce this for the next major release Q2 2010. I am sorry for not being able to help at this time.
Regards,
Martin Vasilev
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.
I'm having the same issue with RowValidating. Depending on why you've set up selectionmode (row, cell, etc), you could potentially carry out the kind of test you want.
In my case, I'm not allowing multiple row select, and I have the selection mode set to full row. So, I know that the row whose cell is be editing is also the row (and the only one) selected. Then, I can do the kind of compariing you talked about under the ValueChange event of the cell:
Private Sub RGV_StdEnrl_ValueChanging(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.ValueChangingEventArgs) Handles RGV_StdEnrl.ValueChanging
If TypeOf sender Is Telerik.WinControls.UI.RadTextBoxEditor Then
Dim ri As GridViewRowInfo = RGV_StdEnrl.SelectedRows(0)
Dim rte As Telerik.WinControls.UI.RadTextBoxEditor = CType(sender, Telerik.WinControls.UI.RadTextBoxEditor)
If e.NewValue <> "" Then
If IsNumeric(e.NewValue) = False Then
MsgBox("Must enter a number")
e.Cancel = True
ElseIf CInt(e.NewValue) < 0 Or CInt(e.NewValue) > 100 Then
MsgBox("Final mark must be between 0 and 100.")
e.Cancel = True
ElseIf RGV_StdEnrl.Columns("ColAttn").IsVisible AndAlso IsDBNull(ri.Cells("ColAttn").Value) = False Then
If e.NewValue > ri.Cells("ColAttn").Value Then
MsgBox("Here, I'm comparing the value entered in one cell to the existing value in the cell under the column 'ColAttn'.")
End If
End If
End If
End If
End Sub
This seems to work quite well for me. Hope this can help with your situation.
Regards,
Justin
Private Sub RadGridViewD_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGridViewD.Leave
'call validation events when we leave the grid if row was modified (won't be called otherwise)
If Me.RadGridViewD.CurrentRow IsNot Nothing AndAlso Me.RadGridViewD.CurrentRow.IsModified Then
Dim ev1 As New RowValidatingEventArgs(Me.RadGridViewD.CurrentRow)
Me.RadGridViewD_RowValidating(Me.RadGridViewD, ev1)
If Not ev1.Cancel Then
Dim ev2 As New RowValidatedEventArgs(Me.RadGridViewD.CurrentRow)
Me.RadGridViewD_RowValidated(Me.RadGridViewD, ev2)
End If
End If
End Sub
Since I am unable to reproduce described issue with Q3 2010 SP1, could you share some more details on your project? This will help me to investigate your particular case and allow us to address any potential bugs with row validating events for the next releases.
I look forward to your reply.
Regards,
Martin Vasilev
the Telerik team
The header grid calls:CellBeginEdit, CellEditorInitialized, CellValidating, CellValueChanged, CurrentRowChanged, GroupSummaryEvaluate, RowsChanged, RowValidated, RowValidating, and ViewCellFormatting. The detail grid calls CellBeginEdit, CellEditorInitialized,CellEndEdit, CellValidating, RowValidated, RowValidating, and ViewCellFormatting.
Thank you for the additional details.
I have tested the RowValidated event once again and it is thrown as expected when RadGridView loses focus. I used Q3 2010 SP1 (2010.3.10.1215) version for my tests. However, looking at your screenshots I see that you have a quite complex scenario, and it is possible that there is something specific which causes the reported issue.
If I understand you right, you have found a work-around for you case. However, I would still like to investigate the issue further. To do that, I need a sample project, which demonstrates the issue. Could you strip only a part of your code and send it as a small example to allow us looking into this issue? In order to be able to send us your project, you have to open a new support ticket.
Kind regards,
Martin Vasilev
the Telerik team
Thank you for contacting us.
I am afraid I am not able to understand your scenario very well. Could you please describe your goal in detail? Some sample code would also be helpful here. This will help me to investigate your case further and provide you with accurate assistance
Best wishes,
Martin Vasilev
the Telerik team
Hi,
same problem with version 2017.2.613.40.
When I leave the parent control from the RadGridView. Only RadGridView Leave event is firing.
But no RowValidating, RowValidated, CellValidating, CellEndEdit.
When I'm leaving the control, I'm currently in an CellSpinEditor. Maybe that helps for reproducing.
My Cell specifications are:
GridViewDecimalColumn
Column..FormatString = "{0:0.###}";
Hi,
I created a test project. With that it works fine. Now I search the fault at my project.
Thanks.
Thank you for writing.
When you leave RadGridView, the RowValidated event will be fired if the CausesValidation property is set to true. You can check if it is set to false in your project.
If you are still experiencing any further difficulties, feel free to submit a support ticket where you can provide a sample project demonstrating the problem you are facing. Thus, we would be able to investigate the precise case and assist you further.
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Progress Telerik