RadGrid Aggregates

9 posts, 0 answers
  1. Keith
    Keith avatar
    1 posts
    Member since:
    Jul 2008

    Posted 08 Jul 2008 Link to this post

    I’m currently in the process of evaluating the RadGrid.

     

    If I add aggregates to the radgrid can I get the aggregate output to display at the bottom of the row as opposed to along side the grouping label. At the very least can I get the information to go above the row that’s being aggregated.

     

    For example in the samples you have a table with a column called quantity, I want to sum the quantity column by adding an aggregate (which is simple to do) and I want to display the sum value below all the quantity values for the grouping, how ever its currently being displayed beside the label.

     

    Thanks  

  2. Hristo Deshev
    Admin
    Hristo Deshev avatar
    559 posts

    Posted 09 Jul 2008 Link to this post

    Hi Keith,

    Unfortunately displaying aggregate results below or above the column is not currently possible. We have plans for adding a new type of row: totals row, that will allow you to position your aggregate results directly below (or above FWIW) the source group.

    We will not be able to ship that feature for our first release, scheduled due July 22.

    Kind regards,
    Hristo Deshev
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Trevor
    Trevor avatar
    6 posts
    Member since:
    Sep 2007

    Posted 25 Jul 2008 Link to this post

    Hello,

    I am also currently evaluating Telerik Rad Grid and am trying to use the Custom Aggregate event. Can you provide a sample of code to show how this may be accomplished using multiple columns, for example:

    Aggregate = (column1, row1 * column2, row1) + (column1, row2 * column2, row2) + (column1, row3 * column2, row3)

    Any help would be greatly appreciated. If I can show that this is possible, we will be buying your product.

    Thank you!
  4. Hristo Deshev
    Admin
    Hristo Deshev avatar
    559 posts

    Posted 29 Jul 2008 Link to this post

    Hello Trevor,

    I am sorry for taking so long to reply. First I thought this would be an easy job for our aggregate functions, but I was wrong.

    When designing the aggregates support in RadGridView for WPF we wanted to abstract aggregate functions in separate classes and allow users to plug their own. That means that users should not attach to an event, but rather inherit from AggregateFunction, and override its Calculate method. In your Calculate method override you will get a GroupRecord that exposes its DataRecord objects and their respective data items which should be enough for implementing your requirement.

    Unfortunately things turned out a bit different. We seem to have introduced a bug that makes implementing your own aggregates impossible. I have scheduled some time for fixing this, and I will be able to send you a hotfix that allows implementing custom aggregates. If that sounds OK, please open a separate support ticket where I can attach the build when we get the fix in place the next couple of days.

    Regards,
    Hristo Deshev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Trevor
    Trevor avatar
    6 posts
    Member since:
    Sep 2007

    Posted 29 Jul 2008 Link to this post

    Hi,

    I'm glad that you found a bug with this, but i regret to inform you that I meant to post this under Rad Controls for ASP.Net AJAX. Would this be a bug in those controls as well? I'm looking forward to your reply.

    Kind regards,
    Trevor
  6. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 30 Jul 2008 Link to this post

    Hello Trevor,

    You can use the demo below as a starting point:

    http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/GeneralFeatures/Aggregates/DefaultCS.aspx

    See the custom aggregate crated for the CustomerID column at the end. The value is set to the arguments.Result in the CustomAggregate event handler at the code-behind.

    If I understand your requirement properly, what you need is to access specific cells data to customize the result. You can set DataKeyNames for the MasterTable including the columns you're going to access data from, get the Items or AlternatingItems of the Grid and get the data through the key values. Here is an example you can customize further according to your needs:

            protected void RadGrid1_CustomAggregate(object sender, GridCustomAggregateEventArgs e) 
            { 
                GridItem[] items = RadGrid1.MasterTableView.GetItems(GridItemType.Item); 
                GridDataItem firstItem = items[0] as GridDataItem; 
                GridDataItem lastItem = items[items.Length - 1] as GridDataItem; 
     
                e.Result = "The OrderID starts from " + firstItem.GetDataKeyValue("OrderID") + " and lasts to " + lastItem.GetDataKeyValue("OrderID"); 
            } 
     

    The required setting for the above sample to function in the markup follows:

                <MasterTableView .. DataKeyNames="OrderID">

    <telerik:RadGrid id="RadGrid1" runat="server ...> 
        <MasterTableView .. DataKeyNames="OrderID"
    </telerik:RadGrid> 

    I hope this helps. If you need further assistance, do not hesitate to contact us again.

    Kind regards,
    Konstantin Petkov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. Keith Woods
    Keith Woods avatar
    4 posts
    Member since:
    Nov 2009

    Posted 02 Dec 2009 Link to this post

    How funny, I'm back looking at grid selection for another financial application and I find my own question from over a year ago!!!

    Has there been any change on this feature, again its key for financial applications and ease of readability.

    Keith
  8. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 03 Dec 2009 Link to this post

    Hi Keith,

    RadGridView can display aggregates in both group header and footer - please check this demo for more info.

    All the best,
    Vlad
    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.
  9. gao
    gao avatar
    6 posts
    Member since:
    Nov 2010

    Posted 25 Jul 2011 Link to this post

    I had a problem .
    When I use the aggregates in the group header, the component was initialized with missing first line.
    For example,
    you can see only two lines with total three items existed.
    But if you click or reset the grouby-by  item, the missing item will  come out, then you will see three items.
    What's wrong with my codes? using MVVM

    <Grid x:Name="rightContent">
                                    <Border telerikQuickStart:ThemeAwareBackgroundBehavior.IsEnabled="True" />
                                    <telerik1:RadGridView x:Name="RadGridView1" ItemsSource="{Binding NodeList, Mode=TwoWay}" CanUserFreezeColumns="False"
                                 AutoExpandGroups="True" AutoGenerateColumns="False" Loaded="RadGridView1_Loaded" telerik1:StyleManager.Theme="Windows7">
                                        <telerik1:RadGridView.Columns>
                                            <telerik1:GridViewDataColumn Header="SequenceNum" DataMemberBinding="{Binding SequenceNum}" />
                                            <telerik1:GridViewDataColumn Header="NodeId" DataMemberBinding="{Binding NodeId}" />
                                            <telerik1:GridViewDataColumn Header="NodeText" DataMemberBinding="{Binding NodeText}" />
                                            <telerik1:GridViewDataColumn Header="OverDueDate" DataMemberBinding="{Binding OverDueDate}" />
                                            <telerik1:GridViewDataColumn Header="NodeStatusId" DataMemberBinding="{Binding NodeStatusId}" />
                                            <telerik1:GridViewDataColumn Header="ProjectId" DataMemberBinding="{Binding ProjectId}" UniqueName="ProjectId">
                                                <telerik1:GridViewDataColumn.AggregateFunctions>
                                                    <telerik1:CountFunction Caption="The number of nodes not started:" />
                                                </telerik1:GridViewDataColumn.AggregateFunctions>
                                            </telerik1:GridViewDataColumn>
                                            <telerik1:GridViewDataColumn Header="Owner" DataMemberBinding="{Binding Owner}" />
                                        </telerik1:RadGridView.Columns>
                                    </telerik1:RadGridView>
                                </Grid>

    private void RadGridView1_Loaded(object sender, System.Windows.RoutedEventArgs e)
            {

                gridViewModel = new GridViewModel();

                this.DataContext = gridViewModel;
                var descriptor = new ColumnGroupDescriptor { Column = this.RadGridView1.Columns["ProjectId"] };
                this.RadGridView1.GroupDescriptors.Add(descriptor);
                   
             
            }


     
Back to Top