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

RowValidating not firing

17 Answers 443 Views
GridView
This is a migrated thread and some comments may be shown as answers.
mtaber
Top achievements
Rank 1
mtaber asked on 03 Jan 2010, 06:20 AM
I have a Grid that is editable by the user and I've got almost everything working. The problem I've run into is that I have this grid on a form that the user can click a button on and close the form. If the user clicks on a textbox column and edits the value, then clicks directly on the "Ok" button to close the form, the data is not validated via the RowValidating event.

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

Sort by
0
mtaber
Top achievements
Rank 1
answered on 05 Jan 2010, 06:04 PM
Does anyone have any ideas on this?
0
Martin Vasilev
Telerik team
answered on 07 Jan 2010, 09:32 AM
Hi mtaber,

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.
0
Ruth Goldberg
Top achievements
Rank 1
answered on 08 Feb 2010, 07:52 PM
I had a similar case in my program. In my case, I have a close button and want to allow the user to close the form and save the current record at the same time. Here's how I do it:

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.

0
Martin Vasilev
Telerik team
answered on 10 Feb 2010, 02:55 PM
Hello Ruth Goldberg,

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.
0
Shulla Krous
Top achievements
Rank 1
answered on 23 Mar 2010, 11:46 AM

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,

0
Martin Vasilev
Telerik team
answered on 25 Mar 2010, 06:51 PM
Hello 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.
0
JustinWong
Top achievements
Rank 1
answered on 11 May 2010, 03:25 AM
Hi Kr Kr:

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
0
Ruth Goldberg
Top achievements
Rank 1
answered on 01 Mar 2011, 04:27 PM
I am using Q3 2010, but my validation events are still not firing when I leave the grid. I have a header grid with multiple rows and a detail grid which links to the current row of the header that has just a few rows, usually just one. When I made a change in the detail and then moved to the header, the row wasn't validating and not saving (because I do that in the Validated event). I got around this problem by calling the validation events with this code in the leave event:
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
0
Martin Vasilev
Telerik team
answered on 04 Mar 2011, 12:05 PM
Hello Ruth Goldberg,

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
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Ruth Goldberg
Top achievements
Rank 1
answered on 07 Mar 2011, 05:31 PM
This particular form is very complex. It has a pageview. The first page is the main one and is always visible. There is a second page that is invisible until a report is generated, and further report pages that can be generated programmatically. The first page has a selection section on top, header and detail grids below it, and buttons below that. A screen shot is attached with dates selected and some data in the grids. The header grid is empty until the Search button is clicked. Then the grid is filled by a custom header TableAdapter method called FillBySelect that adds the search criteria to the Where clause of the regular Fill method of the header TableAdapter. The detail grid is filled in the header grid's CurrentRowChanged event, by calling the detail TableAdapter Fill method with a record key parameter. Both grids can be edited. Editable columns display in blue, readonly columns in black. The grid also has multicolumncombo columns, which can be filtered. There are quite a number of events called for each grid.
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.
0
Martin Vasilev
Telerik team
answered on 10 Mar 2011, 12:40 PM
Hi Ruth Goldberg,

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
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Marc Roussel
Top achievements
Rank 2
answered on 26 May 2011, 07:10 PM
Here I'm with this trying to figure out how to enable a button I disabled and the right place for me was like the RowValidated but as I saw with the version 419 today,  The RowValidated is called only once the GridView loose focus however it's called RowValidated hence it should be fired when the row is validated.
0
Martin Vasilev
Telerik team
answered on 31 May 2011, 01:59 PM
Hello Marc,

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
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
0
Marc Roussel
Top achievements
Rank 2
answered on 31 May 2011, 08:06 PM
Oh sorry forget about it.  I was having issues at the time I wrote this but was solved in a support ticket
0
Heiko Schindler
Top achievements
Rank 1
answered on 04 Oct 2017, 02:53 PM

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.###}";

0
Heiko Schindler
Top achievements
Rank 1
answered on 04 Oct 2017, 03:42 PM

Hi,

I created a test project. With that it works fine. Now I search the fault at my project.

Thanks.

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 05 Oct 2017, 11:04 AM
Hello, Heiko,  

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
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
mtaber
Top achievements
Rank 1
Answers by
mtaber
Top achievements
Rank 1
Martin Vasilev
Telerik team
Ruth Goldberg
Top achievements
Rank 1
Shulla Krous
Top achievements
Rank 1
JustinWong
Top achievements
Rank 1
Marc Roussel
Top achievements
Rank 2
Heiko Schindler
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or