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

GridTemplateColumn with a "Custom" aggregate.

1 Answer 209 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John Fetherolf
Top achievements
Rank 1
John Fetherolf asked on 28 Mar 2013, 05:24 PM
I added a custom aggregate to a column that has an item template because it has a nifty rad tooltip to go with it.  Anyway when I return the custom aggregate from the event, the grid adds the string "Custom : " to the footer cell, and I am wondering why?  Also is there any other way to get rid of that other than what I had to do which was handle the footer cell in the ItemDataBound event as below?

Thanks,
Kevin
<telerik:GridTemplateColumn AllowFiltering="false" UniqueName="OtherPay" HeaderText="Other<br />Pay">
    <ItemTemplate>
        <asp:Label runat="server" ID="lblOtherPay">0</asp:Label>
        <telerik:RadToolTip runat="server" ID="ttPPED" TargetControlID="lblOtherPay" Position="BottomRight"
            Title="Other Pay" AutoCloseDelay="3000" Sticky="true" RelativeTo="Element"
            EnableShadow="false" EnableEmbeddedSkins="false" Skin="KMBlack">
        </telerik:RadToolTip>
    </ItemTemplate>
    <HeaderStyle Width="8%" HorizontalAlign="Right" />
    <ItemStyle HorizontalAlign="Right" />
    <FooterStyle HorizontalAlign="Right" />
</telerik:GridTemplateColumn>


protected void grid_CustomAggregate(object sender, GridCustomAggregateEventArgs e) {
    switch(e.Column.UniqueName) {
        //  For some reason adds the string "Custom : " to the footer cell...
        case "OtherPay":
            e.Result = string.Format("{0:#,##0}", _otherPayTotal);
            break;
    }
}
 
protected void gridPayPlanEntries_ItemDataBound(object sender, GridItemEventArgs e) {
    GridFooterItem footerItem = e.Item as GridFooterItem;
 
    //  Very strange Telerik issue here.  You may ask yourself, why didn't
    //  we do this as a custom aggregate on the GridTemplateColumn for other
    //  pay?  Well for some reason Telerik was adding the text "Custom : "
    //  to the cell in the footer with no apparent way to get rid of it.
    //  Doing it here is kind of a pain, but it works.
    if(footerItem != null) {
        footerItem["OtherPay"].Text = string.Format("{0:#,##0}", _otherPayTotal);
        return;
    }
}

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 02 Apr 2013, 10:19 AM
Hello Kevin,

RadGrid adds the name of the Aggregate function by default. You can use the following property to customize it:
<telerik:GridTemplateColumn ... Aggregate="Custom" FooterAggregateFormatString="{0}">

Hope this helps. Please give it a try and let me know if it works for you.

Greetings,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
John Fetherolf
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or