We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Adding a Formula on a Summary column by programmation

Thread ID:

Created:

Updated:

Platform:

Replies:

73970 May 27,2008 10:58 AM May 29,2008 08:33 AM Windows Forms 4
loading
Tags: GridControl
Gilles Carreau
Asked On May 27, 2008 10:58 AM

Hi,

I am using a GridGroupingControl
I have 3 column

SalesPrice
AlreadyChargePourcentage
AmountAlreadyCharge

I put a Summary column on the SalesPrice and AmountAlreadyCharge column

What I would like to do for the AlreadyChargePourcentage column is to take the total the AmountAlreadyCharge column divide by the total of the SalesPrice column

How can I do that by programmation?
Is that possible?

Thanks in advance and have a nice day!








Administrator [Syncfusion]
Replied On May 28, 2008 09:02 AM

One way you can do this is to add a 'placeholder summary' where you want to see the custom calculation. Then handle the QueryCellStyleInfo event and explicitly provide the value of this placeholder summary at the proper time. Here is a minimal sample that shows this technique.
http://www.syncfusion.com/support/user/uploads/CustomSummary_56e925f5.zip


Gilles Carreau
Replied On May 28, 2008 04:44 PM

Hi,

I try to use your code sample in my project
It look like i dont have the right version of the grouping control

Is that possible ?
My version is 2.1.0.9

Does your sample should work with this version?

This line does not pass the compilation
TypeOf e.TableCellIdentity.DisplayElement Is GridSummaryRow

The compiler say that a DisplayElement can never be a gridSummaryRow

What do you think?

Thanks in advance



Administrator [Syncfusion]
Replied On May 28, 2008 06:25 PM

I am using 6.3.0.6, the latest version.

Here is a VB snippet that works for me with the 6.3.0.6 version.

Sub gridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As GridTableCellStyleInfoEventArgs)
'If TypeOf e.TableCellIdentity.DisplayElement Is GridSummaryRow AndAlso Not (e.TableCellIdentity.SummaryColumn Is Nothing) AndAlso e.TableCellIdentity.SummaryColumn.Name = "sumCol1" Then
If Not (e.TableCellIdentity.SummaryColumn Is Nothing) AndAlso e.TableCellIdentity.SummaryColumn.Name = "sumCol1" Then

Dim row As GridSummaryRow = e.TableCellIdentity.DisplayElement '

e.Style.BackColor = Color.LightGoldenrodYellow
Dim dCol2, dCol3 As Double
If Double.TryParse(GridEngine.GetSummaryText(row.ParentGroup, "sumRow", "sumCol2"), dCol2) And Double.TryParse(GridEngine.GetSummaryText(row.ParentGroup, "sumRow", "sumCol3"), dCol3) And Math.Abs(dCol3) > 0.0000001 Then
e.Style.CellValue = dCol2 / dCol3
End If
End If
End Sub 'gridGroupingControl1_QueryCellStyleInfo



Gilles Carreau
Replied On May 29, 2008 08:33 AM

Hi,

I already try this code yesterday
Like I said it does not pass the compilation

I have an old version of the grid Syncfusion
so that might be the problem

Anyway I want to thank you for your support

Have a nice day!


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;