Adding a new child row when no master row selected.

6 posts, 0 answers
  1. Jim
    Jim avatar
    68 posts
    Member since:
    Apr 2011

    Posted 27 Jan 2012 Link to this post

    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

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 27 Jan 2012 Link to this post

    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 >>

  3. Jim
    Jim avatar
    68 posts
    Member since:
    Apr 2011

    Posted 30 Jan 2012 Link to this post

    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
  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 31 Jan 2012 Link to this post

    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 >>

  5. Jim
    Jim avatar
    68 posts
    Member since:
    Apr 2011

    Posted 31 Jan 2012 Link to this post

    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
  6. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 31 Jan 2012 Link to this post

    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 >>

Back to Top