CellValidating event question

1. When user inputs an invalid value for a cell, we can use ErrorText to show an error message in the RowHeaderColumn. Normally, the ErrorText will be cleared after the user corrects the value. Sometimes the user will just press Esc key to cancel the input value, in this case the CellValidating event won't get fired and the ErrorText will remain shown on the RowHeaderColumn. This behavior will make the user feel confused.

2. We often have many columns to be shown in the grid and the user can use horizontal scroll bar to scroll to the region (s)he likes. When the user scrolls to the right, the ErrorText icon will still show up when a cell receives invalid value. But there is no ErrorText tooltip when the user moves the mouse over the ErrorText icon.

3. We use HtmlViewDefine to arrange the columns in 2-row display. In this case, the row indicator and the columns will overlap with each other when the user scrolls the grid horizontally. And the ErrorText tooltip won't be shown as we described in the 2nd issues.

Thanks in advance.

BR/shortie

Answer

Jack

1.CellValidating event occurs only when a cell value is changed. In case when Esc is pressed, the value remains the same and no validation is needed. However, you can handle CellEndEdit event in this case and reset the ErrorText property.

2. I confirm that this is an issue. Thank you for reporting it. We will address it in our upcoming release. I have updated your Telerik points for this bug report.

3. This is a theme issue. You can work around it by using the ViewCellFormatting event:

NORIS

Hello Jack,
Regarding: 1.CellValidating event occurs only when a cell value is changed. In case when Esc is pressed, the value remains the same and no validation is needed. However, you can handle CellEndEdit event in this case and reset the ErrorText property.

I am doing an Add New Row. The first two columns can not be null. If no text is entered in the these columns the CellEndEdit is not fired, and obviously as you stated, the CellValidating is not either. Even if I click in the cells and click out the CellEndEdit is not fired, so I am unable to update the ErrorText. The grid allows the row to be added into the grid w/o text in these two columns. Since I am using the DataSource as SQL data table It will get a data error when I try to update.
How do I not allow them not to leave the new row unless there is text in the first two columns?
If code is provided, please use VB.
Thank you.

After more testing I wanted to let you know that on the new row the DataError is fired if I click in a cell that can not be null. If I do not enter the cell that can not be null the DataError is not fired.

Jack

This exception should not appear when using our latest release - Q2 2009 SP1. Could you please confirm that you are using this version? You can use RowValidating event to validate new rows. Here is a sample:

Here, we access new row cell values by using the DataRowInfo property, which contains the row that is being added. However, when there is an active editor, its value is not yet saved and you should use ActiveEditor property to get the actual value. I admit that this is a little unintuitive and we will improve our API in one of our upcoming releases.

Jack

ErrorText is related to GridViewDataRowInfo and it can't be set at a cell level. However, you can use CellValidating or CurrentCellChanged events to update its value. Please, don't hesitate to write me if you have further questions.

Ayman

hi
What is the event fired when esc button pressed twice in rad gridview in winforms
and
Is there a away to check if the first row of the grid (row index [-1]) has a data in its cells
and still not entered to new row

thanks

Anton

The event that is fired is when you press two times Esc button is KeyPress. However, if RadGridView is in edit mode on first key press, the CellEndEdit event will be fired and on the second key press the KeyPress event will be fired.

As to your second question, I am not sure that I fully understand your scenario following the provided information. Please open a new support ticket and send us a sample application that demonstrates the case and I will be glad to help further.

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.