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

How to validate a newly created row

3 Answers 62 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mike Maddux
Top achievements
Rank 1
Mike Maddux asked on 23 Mar 2010, 10:03 PM
Hi!

I'm using the rad controls for Silverlight 4 beta.

I have a GridView with a row details expansion.  I'm using a "Required" attribute on the textboxes in the expansion.  When the user edits an existing row and deletes the text in a field that is required, the validation is executed when the field loses focus and the field properly changes its appearance and displays a message.  This is exactly what I want.

However, when the user creates a new data item, which cause me to insert a new Entity to my ObservableCollection and create a new GridViewRow at the top of the grid, he can then click save, without entering any data, and no validations are executed, even though all of the required fields are empty.  Is there anyway for me to cause validation to occur on these fields?

Thanks,

Mike

3 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 24 Mar 2010, 03:19 PM
Hello Mike Maddux,

Generally RadGridView validation is triggered when edit is about to end.
So you have to put this new row in edit mode with code similar to the following:

this.radGridView.ScrollIntoViewAsync(this.radGridView.Items[0]
                , this.radGridView.Columns[2]
                , (f) =>
                {
                    GridViewRow row = f as GridViewRow;
                    if (row != null)
                    {
                        row.IsSelected = true;
                        ((GridViewCell) row.Cells[2]).BeginEdit();
                    }
                });

The example code brings first item (index 0) into view and immediately puts third cell (index 2) into edit mode.
Let me know if this does not help.

Kind regards,
Nedyalko Nikolov
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
Mike Maddux
Top achievements
Rank 1
answered on 24 Mar 2010, 04:18 PM
Thanks for your quick reply!

I can see that the technique you propose would put one cell in a row into edit mode.  But how would I put a row details expansion of a grid row into edit mode?

Thanks,

Mike
0
Nedyalko Nikolov
Telerik team
answered on 26 Mar 2010, 06:36 PM
Hello Mike Maddux,

Generally "Row Details expansion" is just a detail preview of the row content, and you can put whatever you like inside it.  "RowDetails" presenter doesn't have edit mode, if you want to enable editing you have to do it manually (place controls with two bindings and so on). You can use the fact that "RowDetails.DataContext" is same as the row.DataContext. Hope this helps.

Kind regards,
Nedyalko Nikolov
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.
Tags
GridView
Asked by
Mike Maddux
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Mike Maddux
Top achievements
Rank 1
Share this question
or