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

Adding a new child row when no master row selected.

5 Answers 73 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jim
Top achievements
Rank 1
Jim asked on 27 Jan 2012, 09:19 AM
I have two radgridviews, say countries and cities.
Cities is linked to the country grids selected item.
Now if I select a country it display it's cities.
And I can add a city using "Click here to add new item"
However if the user doesn't select a country or there are no countries loaded then I can still add a row to cities.
I know how to intercept the cities "AddingNewDataItem"
Is there any way to determine if the cities is linked to a valid country.

Thanks
Jim

5 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 27 Jan 2012, 04:39 PM
Hi Jim,

 If I have understood you right, the DataContext of the Cities GridView is the Country's GridView SelectedItem.
If this is the case, then when the "AddingNewDataItem" event is raised, you could check if the DataContext of the Cities GridView is a valid one.

I hope that this helps.

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Jim
Top achievements
Rank 1
answered on 30 Jan 2012, 08:45 AM
Datacontext always seems to be the top level object name.
The country/city are within this object.
So with country selected or country not selected the data context is always the same within the cities "AddingNewDataItem"

Jim
0
Dimitrina
Telerik team
answered on 31 Jan 2012, 11:28 AM
Hi Jim,

 When this event is fired, what is the value of the "e.OwnerGridViewItemsControl.ParentRow" ('e' is the GridViewAddingNewEventArgs)?

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Jim
Top achievements
Rank 1
answered on 31 Jan 2012, 03:48 PM
It's always "Nothing"
1) When the grids parent is empty or not selected it's nothing
2) When the grids parent has a selected row it's still nothing.

After 2) if I select anothe parent row and then reselect the original row the child row re-appears, So 2) works Ok

Jim
0
Dimitrina
Telerik team
answered on 31 Jan 2012, 04:00 PM
Hi,

Would you please share how have you implemented the Master/Child relation? 

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Jim
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Jim
Top achievements
Rank 1
Share this question
or