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

[Solved] Hierachical Grid, GridViewColumnSelect and Delete

2 Answers 94 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
UGH!!
Top achievements
Rank 1
UGH!! asked on 03 Aug 2011, 03:37 AM

What I'm trying to accomplish here is a in a hierachical grid, with the child grid using a gridviewcolumnselect populated with an observablecollection. When I select the header to check all the items in the childgrid, I want to delete them and remove them in the observablecollection. Not getting it to work exactly right. The item is not visibly removed from the observablecollection - although the record gets deleted. And the removal from the observablecollection triggers another selectedchangeevent.  Here's my code .... any help would be soooo helpful.

private void _childGrid_SelectionChanged(object sender, SelectionChangeEventArgs e)
        {
            if (setPrompt == false)
            {
                RadWindow.Confirm("Are you sure you want to remove the selected instance(s)?", (s, args) =>
                 {
                     if (args.DialogResult.HasValue && args.DialogResult.Value)
                     {
                         RadGridView gv = e.OriginalSource as RadGridView;
 
                         foreach (var item in gv.Items)
                         {
                             var row = gv.ItemContainerGenerator.ContainerFromItem(item) as GridViewRow;
                             if (row != null)
                             {
                                 if (row.IsSelected == true)
                                 {
                                     UsersTableItem ti = row.DataContext as UsersTableItem;
                                     string selectedInstanceID = ti.InstanceID.ToString();
 
                                     AppInstances.RemoveAppInstance(selectedInstanceID);
                                     ti.Children.Remove(ti);
                                     //ViewModel.LoadData();
                                 }
                             }
 
                         }
                     }
                 });
            }
            setPrompt = true;
        }

2 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Ivanov
Telerik team
answered on 03 Aug 2011, 08:54 AM
Hi Tammy,

I have prepared a sample project that reproduces your scenario.  Please, refer to it and let me know whether this approach meets your requirements.

Best wishes,
Ivan Ivanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
UGH!!
Top achievements
Rank 1
answered on 03 Aug 2011, 01:54 PM
Absolutely perfect!  Just what I needed to get to the final result. Thanks so much!
Tags
GridView
Asked by
UGH!!
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
UGH!!
Top achievements
Rank 1
Share this question
or