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

How to bind Footer to data outside of ItemsSource?

1 Answer 80 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dan Kinchen
Top achievements
Rank 1
Dan Kinchen asked on 29 Apr 2010, 08:53 PM
Hello,

What I am trying to accomplish is to bind the data in a column's footer to something other than the results of an aggrigate function.  The reason for this is the aggregates I am trying to display are conditional based on values from other columns.  For example if I have a property called IsValid and another property called MyValue I want to show an aggregate of the sum of MyValue where IsValid is true.  I have found no clean way to do this with the way the custom aggregates are built.  They are only aware of the value of the column they are in.

What i would rather do is maintain a TotalRow object that contains the same fields as the objects in the ItemsSource but I will maintain the values in those fields by calling my own custom code when the values change from the ItemsSource.  Basically I want to do this:

<telerikgrid:GridViewDataColumn.Footer> 
     <TextBlock Text="{Binding TotalRow.MyValue}"/>  
</telerikgrid:GridViewDataColumn.Footer> 

However, the above does not appear to work.

Any assistance is appreciated.

Dan

1 Answer, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 30 Apr 2010, 08:39 AM
Hello Dan Kinchen,

The sample project attached demonstrates a way to have a custom aggregate function which  provides result based on more than one column. Please have a look at the MyAggregateMethod() , where total is based on two columns - Value1 and Value2.


If you decide not to use this approach, to bind the footer content to something "out-of-the-grid" , it is achievable. You will need to place the source in a Static resource in your page and in the footer template use syntax like :
Text = "{Binding Path = XXXXX, Source={StaticResource XXXXX}}"

All the best,
Pavel Pavlov
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.
Tags
GridView
Asked by
Dan Kinchen
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Share this question
or