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

RadGridView.Items.Groups possible bug

1 Answer 53 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Francisco Amador
Top achievements
Rank 1
Francisco Amador asked on 27 Apr 2010, 07:37 PM
I just downloaded the Telerik controls 2010.1.422.1030 and noticed that the Release Notes stated "The enumerator of RadGridView.Items now enumerates data items only (use RadGridView.Items.Groups to retrieve group items)." Since I had just used the previous way of getting the groups "grid.Items.Cast<IGroup>()", I decided to change that piece of code to the new syntax. Unfortunately I was not able to use it because it keeps returning null.

For comparison I wrote the following code to test out if the previous way still worked (it did).
ReadOnlyObservableCollection<object> groups = grid.Items.Groups; 
int test = grid.Items.Cast<IGroup>().Count(); 
The variable groups would come up null, while the int variable would contain the correct number of groups.

The function that houses my code is being called from a "grid.Dispatcher.BeginInvoke" so it definitely has access to the grid.

Please let me know if you are having the same issues or if I should attempt to create a stripped solution.

Thanks,
Francisco

1 Answer, 1 is accepted

Sort by
0
Francisco Amador
Top achievements
Rank 1
answered on 27 Apr 2010, 10:11 PM
I'm not sure what the cause is, I have been testing it further and have found that the new way works sometimes and the old way works other times in the same instance of the program. The going back and forth between them is what is throwing me off. I attempted to create a stripped down solution, but was unable to recreate the bug (Items.Groups worked all times).

I'm not sure what is causing this to manifest in my program, but for now I have gotten around it by doing the following
ReadOnlyObservableCollection<object> groups = grid.Items.Groups; 
 
IGroup matchingGroup = null
if (groups != null
    matchingGroup = groups.Cast<IGroup>().FirstOrDefault(); 
else 
    matchingGroup = grid.Items.Cast<IGroup>().FirstOrDefault(); 

I'll post again if I find the cause of the bug in my program.
-Francisco
Tags
GridView
Asked by
Francisco Amador
Top achievements
Rank 1
Answers by
Francisco Amador
Top achievements
Rank 1
Share this question
or