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

Programmatic Aggregate

4 Answers 106 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Brice Mason
Top achievements
Rank 2
Brice Mason asked on 28 Jan 2010, 03:24 PM
Hello,

I am attempting to add a count aggregate function to a radGridView programmatically. I first tried to add the following code to my MainPage method as follows:

public MainPage() 
        { 
            InitializeComponent(); 
 
            // load the grid 
            this.radGridView.ItemsSource = EmployeeService.GetEmployees(); 
 
            CountFunction f = new CountFunction(); 
            f.Caption = "Count: "
            ((GridViewDataColumn)this.radGridView.Columns[0]).AggregateFunctions.Add(f); 
        } 

When I rebuild my solution and test this, silverlight just clocks. When I comment out the code which adds the aggregate, rebuild and test, it works fine again.

What I am trying to do is test whether I am able to add aggregates to grids with autogenerated columns. 

As an alternate test, I created a button which when clicked added the aggregate function and displayed it after running the Rebind method on the radGridView. But again my goal is to have the aggregate display when the grid is loaded.

Brice

4 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 28 Jan 2010, 03:27 PM
Hello Brice Mason,

I will try to reproduce the propblem here  , can you please specify the version of the Telerik  DLLs you are using.

All the best,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Brice Mason
Top achievements
Rank 2
answered on 28 Jan 2010, 03:43 PM
Pavel,

Thanks for the quick response.

The version on the GridView DLL is 2009.3.1314.1030

I am using the RadControls for SilverLight Q3 2009 SP 2 which I just downloaded a few days ago.

Thanks,

Brice
0
Pavel Pavlov
Telerik team
answered on 03 Feb 2010, 10:19 AM
Hello Brice Mason,

I found that adding an aggregate function in the constructor is too early when working with autogenerated columns  - as the columns at this stage are not initialized yet.

This is definitely something that needs an improvement by our side, so we are going to fix this.

Meanwhile I am offering the following workaround :

public MainPage()
{
    InitializeComponent();
    this.RadGridView1.ItemsSource = GetListOfItems();
    this.RadGridView1.LayoutUpdated += new EventHandler(RadGridView1_LayoutUpdated);
}
void RadGridView1_LayoutUpdated(object sender, EventArgs e)
{
    this.RadGridView1.LayoutUpdated -= new EventHandler(RadGridView1_LayoutUpdated);
    CountFunction f = new CountFunction();
    f.Caption = "Count: ";
    ((GridViewDataColumn)this.RadGridView1.Columns[1]).AggregateFunctions.Add(f);
    this.RadGridView1.CalculateAggregates();
}


Basically what we do here is to set the aggregate function once , immediately after the grid is rendered.

Regards,
Pavel Pavlov
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Brice Mason
Top achievements
Rank 2
answered on 03 Feb 2010, 03:31 PM
Thanks Pavel, the workaround you provided did the trick.

Brice
Tags
GridView
Asked by
Brice Mason
Top achievements
Rank 2
Answers by
Pavel Pavlov
Telerik team
Brice Mason
Top achievements
Rank 2
Share this question
or