AggregateFunction

7 posts, 0 answers
  1. johanr
    johanr avatar
    3 posts
    Member since:
    Aug 2007

    Posted 28 Sep 2009 Link to this post

    CountFunction function = new CountFunction();
    function.Caption = "Test Caption:";
    group.AggregateFunctions.Add(function);

    group is a GroupDescriptor
    This does not display on the grid.

    How do I create Aggregate functions during runtime?
  2. Ludovic Gerbault
    Ludovic Gerbault avatar
    226 posts
    Member since:
    Apr 2009

    Posted 28 Sep 2009 Link to this post

    I think you forgot the SourceField, which tells your CountFunction what to count exactly.

    Here is a code snippet I use to put an aggregate function on a footer :

                                            SumFunction countFunction = new SumFunction(); 
                                            countFunction.ResultFormatString = "{0:F}"
                                            countFunction.SourceField = r.lib_zone; 
                                            countFunction.Caption = "Total : "
                                            col.AggregateFunctions.Add(countFunction); 
                                         
                                            FormGrille.ShowColumnFooters = true
                                            col.Footer = FormGrille.AggregateResults["countFunction"] ; 

  3. DevCraft banner
  4. johanr
    johanr avatar
    3 posts
    Member since:
    Aug 2007

    Posted 28 Sep 2009 Link to this post

    I tried adding the source field but it made no difference.

    Edit:
    Something i did notice.
    If I sort the grouped column afterwards, the results of the function is shown.
    This might be a refresh problem perhaps.
    Should this happen inside or ourside of a DeferRefresh?
  5. Ludovic Gerbault
    Ludovic Gerbault avatar
    226 posts
    Member since:
    Apr 2009

    Posted 28 Sep 2009 Link to this post

    Quick question before answering, does you scenario require the aggregate function to be done in code instead of doing it in xaml ?
  6. johanr
    johanr avatar
    3 posts
    Member since:
    Aug 2007

    Posted 29 Sep 2009 Link to this post

    Yes, it becomes part of a save and load process of profiles for our application.
    This means that I need to be able to creaet the functions in code as profiles are changed.
    Everything else works great, it's just this one last part that is being a bit of a problem.

    I have descovered that it does indeed add the function but after adding it the UI is not flushed.
    If you perform a action like sorting on a column then all of a sudden the function results are visible.

    So it works but not 100%.
    This happens outside of a defer refresh because defer refresh does not allow you to create group definitions.

    I had a similar UI flush problem with saving column sort information where the column header did not highlight after setting it.
    When I put that in a defer refresh, that ui flush came right that is why I am thinking that this might be something similar, but I don't know how to tell the grid to redraw itself

    What would be perfect is if you could have something like.

    grid.BeginUpdate();
    do some stuff like creation of stuff
    grid.EndUpdate(); <- this does the refresh work for you.
  7. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 30 Sep 2009 Link to this post

    Hi johanr,

    You could try calling RadGridView.Rebind to refresh the UI.

    All the best,
    Milan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. Johan Rabie
    Johan Rabie avatar
    5 posts
    Member since:
    Sep 2009

    Posted 30 Sep 2009 Link to this post

    That certainly did the job.
    Thank you very much, I am very chuffed with the results.
Back to Top
DevCraft banner