This is a migrated thread and some comments may be shown as answers.
CustomAggregrate Group Total
1 Answer 20 Views
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 14 May 2010, 02:23 PM
I'm having trouble getting a group total on a column and I'm not sure what the best way to go about it is.  From my table I"m selecting the fields I need and a calculated field.

Select claims, claimsprocessed, claimsprocessed/claims [percentclaims]...........................

I have the aggregate set to sum for claims and claimsprocessed
I set the aggregate to custom for percentclaims

What I'd like to do is get the totals  for claims and claimsprocessed from the GridGroupFooterItem and calculate the correct total percentage.
Something like:
protected void ARGrid1_CustomAggregate(object sender, GridCustomAggregateEventArgs e)  
{  
   if (e.Item is GridGroupFooterItem)  
   {  
      GridGroupFooterItem itm = (GridGroupFooterItem) e.Item;  
      int totclaims = //Get total claims from footer  ?????
      int  totprocessed = //Get total processed claims from footer  ??????
      e.Result = totprocessed/totclaims;  
 
 
    }  
 
I'm not sure how to get the totals for claims and claimsprocessed out of the GridGroupFooter.  Is that possible? Could you give me an example.

I've looked at the documentation on CustomAggregrates and figure I may have to go the route explained at the bottom of this document: http://www.telerik.com/help/aspnet-ajax/grdtotalsingridfooters.html ,but I figured I might ask to see if what I'm trying to do is possible.

Thanks

1 Answer, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 1
answered on 14 May 2010, 03:45 PM
I figured it out.
I was continually trying to use findcontrol and it was returning null. 
But the following did the trick.

        protected void ARGrid1_CustomAggregate(object sender, GridCustomAggregateEventArgs e)  
        {  
            if (e.Item is GridGroupFooterItem)  
            {  
                GridGroupFooterItem itm = (GridGroupFooterItem) e.Item;  
                string claimsRecvdtxt = itm["ClaimsReceived"].Text;  
                string claimsSysAdj = itm["ClaimsSystemAdj"].Text;  
 
                string[] arclaimsRecvd = claimsRecvdtxt.Split(' ');  
                string[] arclaimsSysAdj = claimsSysAdj.Split(' ');  
 
                int intclaimsRecvd = Convert.ToInt32(arclaimsRecvd[1]);  
                int intclaimsSysAdj = Convert.ToInt32(arclaimsSysAdj[1]);  
 
                e.Result = "Total: " + Math.Round((intclaimsSysAdj*1.0 / intclaimsRecvd)*100,2) + " %";  
 
            }  
 
 
        } 

For a followup question.  It seems group totals get reset by the page, is that correct.  I have some pretty large groupings 1000+ records per group.  I don't really want to set my page size that large. Is there any other way around this?
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Michael
Top achievements
Rank 1
Share this question
or