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

[Solved] RadGridView SelectionChanged event fired 3 times

2 Answers 344 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.
Bruno
Top achievements
Rank 1
Bruno asked on 10 Jul 2009, 06:55 PM
Hi,

I'm using the latest release of telerik's silverlight controls.

In my usage scenario, I have a RadGridView (parentGrid) which contains a Hierarquical RadGridView (childGrid) for each of its records, which on its turn also has subSubGrids ad infinitum. This is basically a SelfReference scenario.

I also have a set of buttons which change depending on the selected record. In theory child rows will have different buttons available than parent rows.

When I select a child record, I noticed that three events are fired in the following order:

1. parentGrid SelectionChanged
        AddedRecords = childRow

2. childGrid SelectionChanged
        AddedRecords = childRow

3. parentGrid SelectionChanged
        AddedRecords = parentRow
        RemovedRecords = childRow

Questions:

A. Why is the last event being fired? Because of this last event, I'm not able to know that the child row was selected and consequently I'm not able to show the correct set of buttons for the child row (rather I will show buttons for the parent row).

B. Is there a way to disable the parent row automatic selection when clicking a child row?

Another situation I've come across is the following:

+ ParentRowA
       - ChildRowA01
+ ParentRowB
       - ChildRowB01
       - ChildRowB02

         1. Select ChildRowA01 from ParentRowA. Result: Both ChildRowA01 and ParentRowA are selected.
         2. Select ParentRowB. Result: ParentRowA is unselected but ChildRowA01 is NOT unselected. Is there any workarround for this?

Many thanks in advance.
Bruno

2 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 15 Jul 2009, 08:16 PM
Hi Bruno,

We are currently investigating the problem and working on a solution. I will contact you once we have resolved the problem.

Thank you for reporting the issue.


Sincerely yours,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Milan
Telerik team
answered on 17 Jul 2009, 12:23 PM
Hello Bruno,

Straight onto the questions. The SelectionChanged event sequence was not correct due to a bug in RadGridView. With the latest build, which should be available today (Latest Internal Build),  when you select a child row the event should be raised only once - notifying that the respective row was selected. Also, the parent row will no longer select when one of its child rows is selected.

Currently all child grids have their own selection which does not influence the selection of the master grid. As a consequence even if you have single selection you could have a record selected in a child grid and in the master grid. Unfortuantely this behavious cannot be turned off. The only workaround that I could think of the the following:

private List<GridViewDataControl> controls = new List<GridViewDataControl>();  
 
void RadGridView1_SelectionChanged(object sender, SelectionChangeEventArgs e)  
{  
    if (e.DataControl != this.RadGridView1)  
    {  
        if (e.AddedItems.Count > 0)  
            this.controls.Add(e.DataControl as GridViewDataControl);  
    }  
    else 
    {  
        foreach (var item in this.controls)  
        {  
            item.SelectedItems.Clear();  
        }  
 
        this.controls.Clear();  
    }  

I am not sure if it will help but you could try it - you just have to subscribe to the SelectionChanged event of the master grid.

Best wishes,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Bruno
Top achievements
Rank 1
Answers by
Milan
Telerik team
Share this question
or