LE DREAU Steeve
Top achievements
Rank 1
LE DREAU Steeve
asked on 02 May 2011, 10:17 AM
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
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
5 Answers, 1 is accepted
0
Hi Steeve,
Vanya Pavlova
the Telerik team
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.
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
0
LE DREAU Steeve
Top achievements
Rank 1
answered on 02 May 2011, 10:49 AM
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
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
0
Accepted
Hello Steeve,
MainPage.xaml.cs
Please let me know how this works for you!
Vanya Pavlova
the Telerik team
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!
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
0
LE DREAU Steeve
Top achievements
Rank 1
answered on 02 May 2011, 01:32 PM
Thanks for your answer, it works very well !
0
Mark
Top achievements
Rank 1
answered on 21 Aug 2013, 11:07 PM
This little ditty was a gem ! ! !