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

Error after upgrading from Telerik Q32009 to Q2 2010

6 Answers 66 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Xaria D
Top achievements
Rank 1
Xaria D asked on 03 Sep 2010, 09:51 AM

I have some aggregrate functions on my gridview like this
 groupview = new QueryableCollectionView(MyListGrid.Items);
                    if (MyListGrid.GroupDescriptors.Count > 0)
                        MyListGrid.GroupDescriptors.Clear();
                    var descriptor = new GroupDescriptor() { Member = "Status" };
                    descriptor.AggregateFunctions.Add(new CountFunction());
                    this.MyListGrid.GroupDescriptors.Add(descriptor);

and I get the following exception at descriptor.AggregateFunctions.Add(new CountFunction());

{"Unable to cast object of type 'Telerik.Windows.Data.QueryableCollectionViewGroup' to type 'Telerik.Windows.Data.AggregateFunctionsGroup'."}

6 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 03 Sep 2010, 09:58 AM
Hello,

 Can you post the stack trace?

Regards,
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
Xaria D
Top achievements
Rank 1
answered on 12 Oct 2010, 10:46 AM
I am having problems after I changed to Q2 2010.
I placed a Breakpoint at  groupview = new QueryableCollectionView(MyListGrid.Items);
and the debugger exits at
this.MyListGrid.GroupDescriptors.Add(descriptor);
the code is as below

 private void LoadTreeViewData(int Id)
        {
            try
            {

                if (MyListGrid.Items.Count > 0 && Id== 1)
                {
                    try
                    {
                       groupview = new QueryableCollectionView(MyListGrid.Items);
                    if (MyListGrid.GroupDescriptors.Count > 0)
                        MyListGrid.GroupDescriptors.Clear();
                    var descriptor = new GroupDescriptor() { Member = "Status" };
                    descriptor.AggregateFunctions.Add(new CountFunction());
                    this.MyListGrid.GroupDescriptors.Add(descriptor);
                     
                       }

                    catch (Exception ex)
                    {
                        MessageBox.Show("LoadTreeViewData :" + ex.Message, "System Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);

                    }
                }
i do not get any exception, the debugger just exits and the UI is not updated at all.
0
Vlad
Telerik team
answered on 15 Oct 2010, 07:42 AM
Hi,

Can you set Visual Studio to break on every exception to see what will be the result? 

Regards,
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
Xaria D
Top achievements
Rank 1
answered on 18 Oct 2010, 04:42 AM
Okay I have a method to handle Grid Grouping
 void FodListGrid_Grouping(object sender, GridViewGroupingEventArgs e)
        {
            try
            {
                if (MyListGrid.GroupDescriptors.Count > 0)
                    this.MyListGrid.GroupDescriptors.Clear();
                this.groupview.GroupDescriptors.Add(e.GroupDescriptor);
                foreach (AggregateFunctionsGroup catgroup in groupview.Groups)
                {
                    var groupresult = catgroup.GetAggregateResults(e.GroupDescriptor.AggregateFunctions);
                    switch (catgroup.Key.ToString())
                    {

and I get an exception at foreach (AggregateFunctionsGroup catgroup in groupview.Groups)
{"Unable to cast object of type 'Telerik.Windows.Data.QueryableCollectionViewGroup' to type 'Telerik.Windows.Data.AggregateFunctionsGroup'."}

I was using the above quote as suggested on this forum in my other post. But I was using Q3 2009 then and now I am using Q2 2010. So what should be done to resolve this? Typecasting does not work, is there a better way to handle this, Kindly let me know.

Thanks
0
Vlad
Telerik team
answered on 18 Oct 2010, 07:44 AM
Hello,

 Have you checked the code in the demo I've posted? With the new version you cannot expect AggregateFunctionsGroup since these are QueryableCollectionViewGroup. Wither use "var" or change your foreach statement. 

All the best,
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
Xaria D
Top achievements
Rank 1
answered on 18 Oct 2010, 08:44 AM
Hi Vlad,

Thanks, I got it working.
Tags
GridView
Asked by
Xaria D
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Xaria D
Top achievements
Rank 1
Share this question
or