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

Validating

4 Answers 272 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Veljko Janjic
Top achievements
Rank 1
Veljko Janjic asked on 26 Dec 2007, 10:21 AM
Can you describe the concept of custom validating of cell content in your GridView. When using validating event I can't figure out what is the cell (its ColumnInfo or RowInfo) which is in edit mode and its content. Why don't args have more properties such as cellElement or columnindex, rowindex ...

Thanks in advance.

4 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 28 Dec 2007, 09:36 AM
Hi Veljko Janjic,

Thank you for writing.

The validation mechanism is currently based on the Validating/Validated events of System.Windows.Forms.Control class. The arguments of RadGridView.Validating event are of type ValueChangingEventArgs but there are no members pointing to the column or row of the edited cell.

Currently, the only way the column and row of the edited cell can be accessed in the event handlers of these events are the following: 

GridViewDataColumn column = radGridView1.MasterGridViewTemplate.CurrentColumn as GridViewDataColumn;
GridViewDataRowInfo row = radGridView1.CurrentRow as GridViewDataRowInfo;

Most probably, the RadGridView API and behavior regarding data validation will be updated and expanded in the upcoming release of our controls.

If you have any additional questions, please contact us again.

Regards,
Georgi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Veljko Janjic
Top achievements
Rank 1
answered on 29 Dec 2007, 03:30 PM
I'm not sure that's the proper way since, user can be in edit mode and when he clicks on some other cell validating event is fired but CurrentRow and CurrentColumn infos are of the latter cell.

I resolved validating issue by passing values to my classes as strings and my classes then validate input, but from the point of long term solution I'm not satisffied with this. I don't want to burden bussines logic classes with formatting issues.

BTW. How can I update group sums after editing some cells? Which event is best for updating the sums and which command should be executed?

Best regards.
0
Georgi
Telerik team
answered on 02 Jan 2008, 01:33 PM
Hello Veljko Janjic,

Indeed, in case the user clicks on the other cell and the Validating event is fired, the CurrentColumn refers to the previous cell (CurrentRow is ok). This appears to be an issue and it is logged to be fixed in the next version. Of course, you should not have to mess the validation logic with your business logic. As another workaround I would suggest hooking the RadGridView.MouseDown event where you could get the current column corresponding to the cell being edited.

In response to your question about grouping, try calling the UpdateGroupPanel method when the new value is validated like this:

void radGridView1_Validated(object sender, EventArgs e)  
{  
    radGridView1.UpdateGroupPanel();  

Thank you for bringing this issue to our attention. Your telerik point balance has been updated.

If you have any further questions, we will be glad to assist you.

Regards,
Georgi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Georgi
Telerik team
answered on 03 Jan 2008, 06:10 PM
Hello Veljko Janjic,

Just a quick follow-up. As another workaround for the issue related to the Validating event, I would suggest getting the current column when the editing begins. You could save the reference to the column in the CellBeginEdit event handler and use it later in the Validating event handler.

Contact us again if further questions arise.

Greetings,
Georgi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
GridView
Asked by
Veljko Janjic
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Veljko Janjic
Top achievements
Rank 1
Share this question
or