Getting aggregate result

6 posts, 1 answers
  1. LE DREAU Steeve
    LE DREAU Steeve avatar
    74 posts
    Member since:
    Aug 2012

    Posted 02 May 2011 Link to this post

    Hi,

    I would like to get the result of an aggregate function into my gridview's footer through code behind. I've searched everywhere but didn't found any solution. Is it possible ?

    Thanks

    Steeve
  2. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 02 May 2011 Link to this post

    Hi Steeve,

     

    I believe that the recommended approach in such case is to perform these calculations at data level.
    For example you may get the items's count just by observing the RadGridView's Items.Count property.
    May you please elaborate a little bit more about your exact settings? Thus we would be able to provide you with an appropriate solution. 


    Best wishes,
    Vanya Pavlova
    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
  3. DevCraft banner
  4. LE DREAU Steeve
    LE DREAU Steeve avatar
    74 posts
    Member since:
    Aug 2012

    Posted 02 May 2011 Link to this post

    In  our scenario, we have to get the result because of filters applied to columns.
    When the user changes Filters, the sum is changed so we would like to get this information. I don't know how to calculate this on data side getting activated filters.

    Our Gridview displays a lot of rows, each one has an amount cell. In the footer, we need to have to Total sum. But if the user filters data, the sum is refreshed in the footer. This is the normal behavior and it's ok for us, it's what we need. But, now, we have to get this information for other purposes.

    Thanks
  5. Answer
    Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 02 May 2011 Link to this post

    Hello Steeve,

     

    Thank you for the detailed information about this case! In such scenario there is an easier way to get the aggregate result for a particular column through accessing the aggregate result of the column you want, please refer to the following:

    MainPage.xaml

    public partial class MainPage : UserControl
        {
            public MainPage()
            {
                // Required to initialize variables
                InitializeComponent();
            }
     
     
            private void RadButton_Click(object sender, RoutedEventArgs e)
            {
                this.txtx1.Text = (this.gridView.AggregateResults[0].FormattedValue).ToString();
            }
        }

    MainPage.xaml.cs

    <telerik:RadGridView Margin="80,32,192,56" x:Name="gridView"  AutoGenerateColumns="False" ShowColumnFooters="True" ItemsSource="{Binding Collection}">
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn Header="P1" DataMemberBinding="{Binding Property1}">
                        <telerik:GridViewDataColumn.AggregateFunctions>
                            <telerik:SumFunction Caption="Total:"/>
                            </telerik:GridViewDataColumn.AggregateFunctions>
                        </telerik:GridViewDataColumn>
                     
                    </telerik:RadGridView.Columns>
                </telerik:RadGridView>
            <Border Background="Red" Width="180" Height="100" HorizontalAlignment="Right">
                <TextBlock x:Name="txtx1" FontSize="16"/>
            </Border>
            <telerik:RadButton Content="Button" Click="RadButton_Click" HorizontalAlignment="Right" Height="24" Margin="0,0,240,8" VerticalAlignment="Bottom" Width="64"/>



    Please let me know how this works for you!


    Kind regards,
    Vanya Pavlova
    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
  6. LE DREAU Steeve
    LE DREAU Steeve avatar
    74 posts
    Member since:
    Aug 2012

    Posted 02 May 2011 Link to this post

    Thanks for your answer, it works very well !
  7. Mark
    Mark avatar
    155 posts
    Member since:
    Oct 2010

    Posted 21 Aug 2013 Link to this post

    This little ditty was a gem ! ! !
Back to Top
DevCraft banner