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

Aggregate function name is not displayed for Columns having custom format applied

3 Answers 214 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nutan
Top achievements
Rank 1
Nutan asked on 07 Dec 2010, 03:49 PM
Hi,

I have a radgrid with dynamic GridBoundColumns created, where we apply custom format string to each of them based on data type
eg: boundColumn.DataFormatString = "{0:N}" for decimal or any number type.

I have support for both server-side and client-side aggregate functionality. But facing some issues now.

Scenario : If we apply a custom DataFormatString to a column
Grid is loaded fine. But if user selects a aggregate type using Footer Aggregate Menu from Column Header, Aggregate Name is not displayed within the footer result.

Aggregate Operation is executed fine and desired result is displayed but we are not able to see the Aggregate name.

Eg: We apply “Count” aggregation on Column1 then the footer result is displayed as “x.
 The expected result should be “Count : x”

It works fine when no dataformat string is applied on bound columns. 

Here is a post which says , which in-turn says aggregate title names can be turned off by seting DataFormatString.
http://stackoverflow.com/questions/1244894/telerik-radgrid-custom-aggregate-unwanted-text

So in our case, its the same that is happening. We are setting the dataformatstring and cant see the aggregate titles.

Need a solution to get this working.
Are there any specific constraints to use in order to support both server side and client side aggregates with formats applied ? Or am I missing anything here ?

Any thoughts ?

3 Answers, 1 is accepted

Sort by
0
Accepted
Martin
Telerik team
answered on 10 Dec 2010, 12:29 PM
Hello Nutan,

Indeed the reported behavior is observed. It is expected when a DataFormatString for a column is set, all its values (the one in the footer as well) to be set in accordance to this format string. Since the format string does not contain the aggregate function name, hence its absence in the footer item.

Fortunately, there is a very straightforward approach that easily implements the required functionality. On the table view's DataBinding event, get reference to the column(s) and set its FooterDataFormatString accordingly:

protected void MasterTableView_DataBinding(object sender, EventArgs e)
{
    GridNumericColumn col = RadGrid1.MasterTableView.GetColumnSafe("ColumnUniqueName") as GridNumericColumn;
    col.FooterAggregateFormatString = col.Aggregate.ToString() + ": {0:C}";
}

The approach above is demonstrated in the following online example (pay attention to the "Unit price" column):

Footer aggregates

I hope this helps.

Greetings,
Martin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Nutan
Top achievements
Rank 1
answered on 22 Dec 2010, 02:57 PM
Thanks Martin.

The solution is fine but i was looking for some property or attribute available that could support in such scenarios.

Adding MasterTableView_DataBinding event supports the scenario.
 
Thanks for your response

0
Martin
Telerik team
answered on 23 Dec 2010, 05:02 PM
Hello Nutan,

The same approach can be used for GridTemplateColumn as well. Attached to this message is a small sample that demonstrates it. Please give it a try and let me know how it goes.

I hope this helps.

Best wishes,
Martin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Nutan
Top achievements
Rank 1
Answers by
Martin
Telerik team
Nutan
Top achievements
Rank 1
Share this question
or