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

Format string summary row

4 Answers 469 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Felice
Top achievements
Rank 1
Felice asked on 05 Jan 2014, 06:41 AM
I have created a summary row like this:

private void radGridView1_Initialized(object sender, EventArgs e)
       {
           this.radGridView1.SummaryRowsBottom.Add(new GridViewSummaryRowItem(new GridViewSummaryItem[]{
           new GridViewSummaryItem("Balance", "{0}", GridAggregateFunction.Sum)}));
           this.radGridView1.MasterTemplate.ShowTotals = true;
           this.radGridView1.MasterView.SummaryRows[0].PinPosition = PinnedRowPosition.Top;
       }
 and I have formatted the text in this way:
private void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
    {
           
        if (e.CellElement is GridSummaryCellElement)
        {
            e.CellElement.TextAlignment = ContentAlignment.MiddleRight;
            Font summaryFont = new Font("Segoe", 9, FontStyle.Bold);
              
            e.CellElement.Font = summaryFont;
        }
    }
How can I set the format string like this {0:R #.##,##}?

4 Answers, 1 is accepted

Sort by
0
Felice
Top achievements
Rank 1
answered on 07 Jan 2014, 06:20 AM
Problem solved.
new GridViewSummaryItem("Balance", "{0:R #.###,##}", GridAggregateFunction.Sum)}));
0
Accepted
Ralitsa
Telerik team
answered on 07 Jan 2014, 02:32 PM
Hi Felice,

I am glad to hear that you find how to set the format string.  You can take a look at our article Summary Rows where it is described how to use and customize the summary rows in the RadGridView

Should you have further questions, I would be glad to help.

Regards,
Ralitsa
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
George
Top achievements
Rank 1
answered on 20 Sep 2017, 08:24 AM
I have used this code  Dim AvgResponseTime As New GridViewSummaryItem("ResponseTime", "{0: #.#}", GridAggregateFunction.Avg) and works . However if the value is 0,9 does not display the zero.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 Sep 2017, 08:30 AM
Hello, George, 

Thank you for writing.  

The "#" symbol indicates an optional digit or space. That is why the value 0.9 is display as .9. You can replace the "#" symbol with "0​" indicating required digits: 
Dim summaryItem As New GridViewSummaryItem("UnitPrice", "{0: 0.0}", GridAggregateFunction.Min)
Dim summaryRowItem As New GridViewSummaryRowItem()
summaryRowItem.Add(summaryItem)
Me.RadGridView1.SummaryRowsTop.Add(summaryRowItem)


Alternatively, you can use the GroupSummaryEvaluate event which is fired after a summary item is calculated and before the summary row is displayed. You can use it to apply custom formatting to the summary row.

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Felice
Top achievements
Rank 1
Answers by
Felice
Top achievements
Rank 1
Ralitsa
Telerik team
George
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or