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

Aggregate Function Code Behind with Dynamic Binding?

1 Answer 241 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Daryl
Top achievements
Rank 1
Daryl asked on 17 Feb 2011, 05:45 PM

*** MODERATOR : This should be in WPF GridView - not sure how to move this & don't want to post twice ****

So I found out from support that the the .Columns collection is not populated until the grid is
shown when bound dynamically. I'm not sure I agree with that functionality.  I should have access to these collections right
after the data is bound.  Anyway, I am trying to add an aggregate function after the data is bound.  My ultimate goal is
to be able to go through my columns, and dynamically apply aggregate functions to the column based on the data type.
As stated below, this will always be dynamically bound, I do not want to define my grid columns via XAML pre-bind since this will
be changing based on the dynamic binding.

Any help would be greatly appreciated!

Thanks!

Daryl

 

 

// I have some code that fills the grid dynamically.  
// This is SUPER important as I will be filling this over and over
// again via some other widget which will bind to different SQL queries when the 
// user clicks the "other widget" - say a tree control full of different queries. 
// I DO NOT want to PREDEFINE what my columns are going to be via XAML

// As a sample, lets say in the load event of the form I fill the grid
// with this SQL 
 
DataTable dt = g.DB.SelectDataTable("select * from category");
MyWPFGridView.ItemsSource = dt;
  
  
// I am trying to create a "dynamic" aggregation function on the
// first column but
// I am not seeing it manifest itself in the grid...
// ALSO:  I am seeing this event get called TWICE...why?
  
void Form1_DataLoaded(object sender, EventArgs e) 
  
{
   Debug.WriteLine("Form1_DataLoaded :: Telerik WPFGrid Column Count: " + MyWPFGridView.Columns.Count); 
   CountFunction f = new CountFunction(); 
   f.Caption = "Count"
   MyWPFGridView.Columns[0].AggregateFunctions.Add(f); 
}

 

1 Answer, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 23 Feb 2011, 05:59 PM
Hi Daryl,

There is no problem to add aggregate functions on the fly (or any button click event, for examples). The only requirement is that the CalculateAggregates function is called right after the new aggregates is added.


Best wishes,
Milan
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
GridView
Asked by
Daryl
Top achievements
Rank 1
Answers by
Milan
Telerik team
Share this question
or