Programmatic Aggregate

5 posts, 0 answers
  1. Brice Mason
    Brice Mason avatar
    7 posts
    Member since:
    Jan 2010

    Posted 28 Jan 2010 Link to this post

    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
  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 28 Jan 2010 Link to this post

    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.
  3. DevCraft banner
  4. Brice Mason
    Brice Mason avatar
    7 posts
    Member since:
    Jan 2010

    Posted 28 Jan 2010 Link to this post

    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
  5. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 03 Feb 2010 Link to this post

    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.
  6. Brice Mason
    Brice Mason avatar
    7 posts
    Member since:
    Jan 2010

    Posted 03 Feb 2010 Link to this post

    Thanks Pavel, the workaround you provided did the trick.

    Brice
Back to Top
DevCraft banner