Nick Anderson
Top achievements
Rank 1
Nick Anderson
asked on 03 Dec 2010, 09:52 PM
How do I use the LastFunction in the AggregateFunctions of a GridViewDataColumn? When I put it in, it only seems to display the string of the underlying datatype of my row, not the value of the column of the last item. Other functions(Sum, min, max) show just fine.
According to the documentation it should work. http://www.telerik.com/help/wpf/gridview-columns-aggregate-functions.html
According to the documentation it should work. http://www.telerik.com/help/wpf/gridview-columns-aggregate-functions.html
5 Answers, 1 is accepted
0
Hi,
Vlad
the Telerik team
Other aggregate functions will work with a specific property while first and last will work directly with the collection. Here is an example how to achieve your goal in this case:
<
telerik:RadGridView
ItemsSource
=
"{Binding}"
ShowColumnFooters
=
"True"
AutoGenerateColumns
=
"False"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding
CustomerID
}"
>
<
telerik:GridViewDataColumn.AggregateFunctions
>
<
telerik:LastFunction
/>
</
telerik:GridViewDataColumn.AggregateFunctions
>
<
telerik:GridViewDataColumn.Footer
>
<
telerik:AggregateResultsList
ItemsSource
=
"{Binding}"
>
<
ItemsControl.ItemTemplate
>
<
DataTemplate
>
<
StackPanel
Orientation
=
"Horizontal"
VerticalAlignment
=
"Center"
>
<
TextBlock
VerticalAlignment
=
"Center"
Text
=
"{Binding Caption}"
/>
<
TextBlock
VerticalAlignment
=
"Center"
Text
=
"{Binding FormattedValue.CustomerID}"
/>
</
StackPanel
>
</
DataTemplate
>
</
ItemsControl.ItemTemplate
>
<
ItemsControl.ItemsPanel
>
<
ItemsPanelTemplate
>
<
StackPanel
Orientation
=
"Vertical"
/>
</
ItemsPanelTemplate
>
</
ItemsControl.ItemsPanel
>
</
telerik:AggregateResultsList
>
</
telerik:GridViewDataColumn.Footer
>
</
telerik:GridViewDataColumn
>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
Vlad
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Rabi82
Top achievements
Rank 1
answered on 31 May 2012, 02:05 PM
hi,
this example are not working ?!
i am working with ObservableCollection<DataRow> my code :
this example are not working ?!
i am working with ObservableCollection<DataRow> my code :
<telerik:RadGridView x:Name="FlowsGridView" Height="330" ColumnWidth="*" ScrollViewer.VerticalScrollBarVisibility="Auto" IsFilteringAllowed="False" CanUserSortColumns="False" ShowGroupPanel="False" AutoGenerateColumns="False" ShowColumnFooters="True" ItemsSource="{Binding FlowsCollection}"> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn DataMemberBinding="{Binding Id}" Header="Id" UniqueName="Id" IsVisible="False" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding BankAccountName}" Header="בנק" UniqueName="BankAccountName" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding FlowDate}" Header="תאריך" UniqueName="FlowDate" DataFormatString="{} {0:dd, MMM, yyyy}" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding FlowTypeName}" Header="סוג" UniqueName="FlowTypeName" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding FlowTypeSumInt}" Header="FlowTypeSumInt" UniqueName="FlowTypeSumInt" IsVisible="False" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding SupplierId}" Header="SupplierId" UniqueName="SupplierId" IsVisible="False" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding SupplierName}" Header="ספק\לקוח" UniqueName="SupplierName" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding SupplierNumber}" Header="מספר ספק\לקוח" UniqueName="SupplierNumber" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding FlowPaymentMethodName}" Header="אמצעי תשלום" UniqueName="FlowPaymentMethodName" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding FlowPaymentReference}" Header="אסמכתה" UniqueName="FlowPaymentReference" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding FlowAmount}" Header="סכום" UniqueName="FlowAmount" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding FinalFlowAmount}" Header='יתרת עו"ש' UniqueName="FinalFlowAmount"> <telerik:GridViewDataColumn.AggregateFunctions> <telerik:LastFunction /> </telerik:GridViewDataColumn.AggregateFunctions> <telerik:GridViewDataColumn.Footer> <telerik:AggregateResultsList ItemsSource="{Binding}"> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" VerticalAlignment="Center"> <TextBlock VerticalAlignment="Center" Text="{Binding FormattedValue.FinalFlowAmount}" /> </StackPanel> </DataTemplate> </ItemsControl.ItemTemplate> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Vertical" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </telerik:AggregateResultsList> </telerik:GridViewDataColumn.Footer> </telerik:GridViewDataColumn> </telerik:RadGridView.Columns> </telerik:RadGridView>thank you
0
Hi,
Vlad
the Telerik team
Can you post more info about your question/problem?
Regards,Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Rabi82
Top achievements
Rank 1
answered on 03 Jun 2012, 07:31 AM
0
Hello,
Didie
the Telerik team
I have reviewed the code snippet you provided. Probably you have missed to specify the correct binding for the AggregateResultsList. Please change your code like so:
<
telerik:AggregateResultsList ItemsSource
=
"{Binding AggregateResults}"
>
Regarding your second question, you should go through our help article about conditionally styling cells.
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>