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

Gridview Footer binding with the Custom data

10 Answers 191 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Harikumar
Top achievements
Rank 1
Harikumar asked on 23 Nov 2010, 09:19 AM


Hi,

I need to bind the Footer column field with the view model property. I dont need the default aggregation values.

Following is my source:

 

 

<telerikGridView:GridViewDataColumn CellStyle="{x:Null}"

 

 

Header="Total Price"

 

 

IsReadOnly="True"

 

 

TextAlignment="Right"

 

 

DataMemberBinding="{Binding TotalPrice, Mode=OneWay, Converter={StaticResource CurrencyValueConverter}}"

 

 

SortMemberPath="{x:Null}"

 

 

Width="Auto" >

 


<

 

telerikGridView:GridViewDataColumn.Footer>

 

 

 

<StackPanel Orientation="Vertical" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="1,1,1,1">

 

 

 

<TextBlock

 

 

VerticalAlignment="Bottom"

 

 

HorizontalAlignment="Right"

 

 

Text="{Binding WorkOrderTotalPrice, Mode=OneWay, Converter={StaticResource CurrencyValueConverter}}" />

 

 

 

</StackPanel>

 

 

 

</telerikGridView:GridViewDataColumn.Footer>

 

 

 

</telerikGridView:GridViewDataColumn>

 


I am using a view model which contains the TotalPrice and WorkOrderTotalPrice properties. I need to bind the WorkOrderTotalPrice property in to the Footer field.

The above source is not working. Please let me know, how could i bind it?

10 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 23 Nov 2010, 09:25 AM
Hello Harikumar,

Firstly, you may take a look at our demo for examples on the way of defining and exploring the column footers. Furthermore, you may try the approach of defining your ViewModel in the Resources section and then use it as a StaticResource as the Source property in the definition of your Binding. 

Greetings,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Harikumar
Top achievements
Rank 1
answered on 23 Nov 2010, 10:24 AM

Hi,

My page's DataContext is already bound with the ViewModel. I am using the MVVM design model. The same page has some other conrtols which has the values bound with the Viewmodel and they are showing the values properly. 

Do i need to put the viewModel as my Static Resource? Then only can i access the values in footer? 
0
Sascha
Top achievements
Rank 1
answered on 23 Nov 2010, 03:41 PM
Hello,

i have the same problem. The textbox shows no data from the viewmodel in the datacontext.

I defined the footer in the xaml like this:

<telerik:GridViewDataColumn Header="Bestellungen" IsGroupable="False" UniqueName="BANZAHL" DataMemberBinding="{Binding BANZAHL}" SortingState="Descending" DataFormatString="N0" TextAlignment="Right" SortMemberPath="BANZAHL" IsVisible="{Binding ColumnBanzahlIsVisibleB}" >
                    
                    <telerik:GridViewDataColumn.Footer>
                        <StackPanel Orientation="Horizontal" >
                            <TextBox Text="{Binding SumBestellungen, Mode=TwoWay}" DataContext="{Binding ElementName=LayoutRoot, Path=DataContext}" />
                        </StackPanel>
                    </telerik:GridViewDataColumn.Footer>
                         
                </telerik:GridViewDataColumn>

But, when i copy the definition of the textbox outside the grid, it immediatly works.

There is no way for me to create the viewmodel as a static resouce because i need some parameters in the constructor.

I think, this is some bug in the Gridview Q3.

Greetings,
Sascha
0
Maya
Telerik team
answered on 25 Nov 2010, 12:07 PM
Hi Sascha,

Indeed one possible approach is to define the ViewModel in the Resources section and use it as a StaticResource afterwards. Another way for handling such a scenario is described in online documentation. The example is based on the Header of the column, but the idea is the same.
 

Kind regards,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Sascha
Top achievements
Rank 1
answered on 26 Nov 2010, 10:56 AM
Hello,

unfortunaly your hint to the online documentation didn't work. The Header and the Footer are still emtpy.
Using a DataContextProxy helped me solving the problem.

Greetings,
Sascha

0
Paul
Top achievements
Rank 1
answered on 07 Jan 2011, 12:22 AM
<telerik:GridViewColumn.FooterCellStyle>
                <Style TargetType="telerik:GridViewFooterCell">
                    <Setter Property="ContentTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <TextBlock Text="{Binding Text, ElementName=TextBlock}" />
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </telerik:GridViewColumn.FooterCellStyle>

In the online documentation link provided, there is an example of binding to a Header.  The trick is bind to a HeaderCellStyle (or FooterCellStyle in my case) instead of binding to the header itself.  Just wanted to share this little piece of info in the event that somebody else was searching for a solution and came across this thread.

Paul
0
Maya
Telerik team
answered on 07 Jan 2011, 08:41 AM
Hello Paul,

Thank you for sharing the code-snippet. It extends the example in our documentation by demonstrating how to achieve the desired result in the columns' footers. 
 

Best wishes,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Viki
Top achievements
Rank 1
answered on 12 May 2011, 12:58 PM
Hi,

I can't get the 'GridViewFooterCell' class from:

"clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"

is it new? from which version?

Thanks,
Viki
0
Maya
Telerik team
answered on 12 May 2011, 01:08 PM
Hi Sascha,

You can get the GridViewFooterCell from:

xmlns:telerik="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView"

However, I would recommend you to use the uri namespace:

Thus you will be able to reference all the controls, whose assemblies have been added to your project and you will not have to take care which namespace exactly you need.

Kind regards,
Maya
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
Viki
Top achievements
Rank 1
answered on 15 May 2011, 08:42 AM
Maya, thanks!

I just had to add the alias for to get the class, as follows:
<telerik:GridViewColumn.FooterCellStyle>
                        <Style TargetType="telerik:GridViewFooterCell">
                        .......
  
and not just:
<telerik:GridViewColumn.FooterCellStyle>
                        <Style TargetType="GridViewFooterCell">
Tags
GridView
Asked by
Harikumar
Top achievements
Rank 1
Answers by
Maya
Telerik team
Harikumar
Top achievements
Rank 1
Sascha
Top achievements
Rank 1
Paul
Top achievements
Rank 1
Viki
Top achievements
Rank 1
Share this question
or