This is a migrated thread and some comments may be shown as answers.

LastFunction in Footer

5 Answers 55 Views
GridView
This is a migrated thread and some comments may be shown as answers.
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

5 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 06 Dec 2010, 08:44 AM
Hi,

 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>


Greetings,
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 :
                <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
Vlad
Telerik team
answered on 01 Jun 2012, 07:32 AM
Hi,

 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
hi,
i am having the same problem as Nick Anderson ,
the LastFunction in the AggregateFunctions of a GridViewDataColumn are not working !!!
i also try the above example you suggest,but also have no luck :(

i am using WPF \ MVVM (also last version of telerik controls of wpf) and my code go like this :

in the  xaml file :               

                <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> 


and i am binding the data from the viewmodel :


 public ObservableCollection<DataRow> FlowsCollection { getset; }



and i have another question if its ok,
haw can customize my gridview so that the cell with value greater than 100 will be in red color ?!!
can you navigate me to the right form or document of telerik ?!


thank you


0
Dimitrina
Telerik team
answered on 04 Jun 2012, 10:36 AM
Hello,

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.

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Nick Anderson
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Rabi82
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or