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

Problem with grouping

2 Answers 36 Views
GridView
This is a migrated thread and some comments may be shown as answers.
jimit r
Top achievements
Rank 1
jimit r asked on 30 Mar 2010, 10:59 AM
Hi team !!

I use the following code to expand a group in my grid:

goalsDataGrid.ExpandGroup(goalsDataGrid.Items.OfType<IGroup>().ElementAt(1));

The groups are of type "Essential" and "Desired". But suppose i haven't added any record of type "Desired", ElementAt(1) refers to a record of type "Desired". 
Now, when i have not yet added an item of type "Desired", obviously the above-mentioned single line of code will throw an ArgumentOutOfRangeException. How do i manipulate the code to expand a group only if it is present?

Regards,
Jimit.

2 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 30 Mar 2010, 12:02 PM
Hi Jimit,

You can use ElementAtOrDefault() which will not raise exception - you will get null if the item cannot be found.

Greetings,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
jimit r
Top achievements
Rank 1
answered on 30 Mar 2010, 04:37 PM
Thanx Vlad!! a lot!!
Tags
GridView
Asked by
jimit r
Top achievements
Rank 1
Answers by
Vlad
Telerik team
jimit r
Top achievements
Rank 1
Share this question
or