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.

Can't add a expression field

Thread ID:





120181 Sep 8,2015 01:43 PM Sep 22,2015 08:51 AM Windows Forms 7
Tags: GridGroupingControl
Pierre Smith
Asked On September 8, 2015 01:43 PM

I am trying to use the examples on the website to add an expression field but it isn't adding it when i run the code

here is the example
ExpressionFieldDescriptor exp1 = new ExpressionFieldDescriptor("Winning %", "([wins] *100)/([wins]+[ties]+[losses])", "System.Double");

ExpressionFieldDescriptor exp1 = new ExpressionFieldDescriptor("Loosing %", "([losses] *100)/([wins]+[ties]+[losses])", "System.Double");

//Adds expression fields to the grid table.

this.gridGroupingControl1.TableDescriptor.ExpressionFields.AddRange(new Syncfusion.Grouping.ExpressionFieldDescriptor[] { exp1, exp2 });

here is my code
ExpressionFieldDescriptor exp1 = new ExpressionFieldDescriptor("Totaal", "[Cost]*2", "System.Double");

can someone please tell me what i am doing wrong

Adhikesevan Kothandaraman [Syncfusion]
Replied On September 9, 2015 08:21 AM

Hi Pierre,

Thank you for using Syncfusion Products.

In the ExpressionFieldDescriptor constructor, we need to pass the columns mapping name that we want to apply the Expression.

Code Example:

//Argument 1: Total is the mapping name of the column which we want to apply the Expression

//Argument 2: Expression like "[Column2] * 2 " Computation with other column values( here "Cost" is another Column name).

ExpressionFieldDescriptor exp1 = new ExpressionFieldDescriptor("Total", "[Cost]*2", "System.Double");

//Adding the expression field to the columns






Pierre Smith
Replied On September 9, 2015 10:25 AM

the Cost field i have in my code is the mapping name not the column name

i will try your example and see if it works thank you

Adhikesevan Kothandaraman [Syncfusion]
Replied On September 10, 2015 02:11 AM

Hi Pierre,

We look forward for your response.


Pierre Smith
Replied On September 10, 2015 04:50 AM


So the problem is when i add my own names to the columns by using a columnset and then changing the visible columns then it becomes a problem where the expression field does not want to display. if i take all the columnset and visible columns away and just use it as a raw gridgroupingcontrol then the expression field works fine

so how do i impliment the expression field when i hide some of the columns and when i rename the columns to something different.

do i have to do it in a specific order ?

thank you

Venkatesh Sundaram [Syncfusion]
Replied On September 11, 2015 08:07 AM

Hi Pierre,

Thanks for your interest in Syncfusion Product.

If the columns are hidden and change in the column name will not affect the expression fields. Since, the display text of the column name only changes, where the columns in the hidden state. The expression field are created using the mapping name. Please refer to the following sample for more reference. 

Sample Link:


Please let me know if you have any concern.


Pierre Smith
Replied On September 21, 2015 04:58 AM

Just an update

The solution you gave me works but I had to figure out why my code is not working
What I discovered is that when I use a GridColumnDescriptorCollection to manually specify the names of my columns you need to add a unbounded column called Total for the expression field
I take it that you use the same name for the Column as what you use for the Expression field is this correct because it seems to work like that.

Adhikesevan Kothandaraman [Syncfusion]
Replied On September 22, 2015 08:51 AM

Hi Pierre,

Thanks for your update.

While adding the expression fields to the TableDescriptor, it will check for the specific field present in the TableDescriptor.Column collection. If the field exist which will apply the expression to that field. Else, it will add a new Field with the expression name. Also, the field which is used for calculating the expression must be visible if you are using the unbound expression field.



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.