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

Selecting an item in a collapsed group programmatically

4 Answers 45 Views
GridView
This is a migrated thread and some comments may be shown as answers.
JDB
Top achievements
Rank 1
JDB asked on 14 Jul 2009, 02:03 PM
Hi,

If I try to select an item programmatically, and that item is in a collapsed group, an IndexOutOfRange exception is thrown. Is there any other way of avoiding this besides expanding all groups?

Thanks in advance!

4 Answers, 1 is accepted

Sort by
0
JDB
Top achievements
Rank 1
answered on 15 Jul 2009, 06:44 AM
Hi,

Thanks to the solution in this thread, I don't get the IndexOutOfRangeException anymore, but now there's an first chance ArgumentOutOfRangeException thrown,
0
Accepted
Milan
Telerik team
answered on 17 Jul 2009, 04:25 PM
Hello RVW,

Currently the best way to overcome this problem is to have expanded groups. We are already working on a solution and we will try to include a fix in next week's Latest Internal Build.

There is one workaround that you could try:

public void BrindIntoView(object dataItem)  
{  
    try 
    {  
        var group = this.FindGroup(dataItem);  
        group.IsExpanded = true;  
        this.RadGridView1.BringDataItemIntoView(dataItem);  
    }  
    catch 
    {  
        this.Dispatcher.BeginInvoke(new Action(() =>   
            this.RadGridView1.BringDataItemIntoView(dataItem)), DispatcherPriority.SystemIdle, null);  
    }  
}  
 
public GroupRecord FindGroup(object dataItem)  
{  
    var record = this.RadGridView1.FindRecord(dataItem);  
    var grp = this.RadGridView1.Records.  
        Cast<GroupRecord>().  
        Where<GroupRecord>((group) => group.Records.Contains(record)).FirstOrDefault();  
      
    return grp;  

Instead of using RadGridView.BrindDataItemIntoView you could try using this new BringIntoView method.

Thanks for reporting this issue. Your Telerik points have been updated.

Regards,
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
JDB
Top achievements
Rank 1
answered on 18 Jul 2009, 04:33 PM
Hi Milan,

Thanks for your answer, I'll try the solution you proposed next thing monday morning!

0
JDB
Top achievements
Rank 1
answered on 20 Jul 2009, 06:39 AM
Hi Milan,

On first sight the solution works, but only if there's only 1 group defined. When multiple are defined, you still get an exception and it doesn't work.

But I'll try to get that to work through recursion, if that won't slow things down too much.
Tags
GridView
Asked by
JDB
Top achievements
Rank 1
Answers by
JDB
Top achievements
Rank 1
Milan
Telerik team
Share this question
or