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. Image for the cookie policy date

Can't add a expression field

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

7 Replies

AK Adhikesevan Kothandaraman Syncfusion Team September 9, 2015 07: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






PS Pierre Smith September 9, 2015 09: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

AK Adhikesevan Kothandaraman Syncfusion Team September 10, 2015 01:11 AM

Hi Pierre,

We look forward for your response.


PS Pierre Smith September 10, 2015 03: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

VS Venkatesh Sundaram Syncfusion Team September 11, 2015 07: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.


PS Pierre Smith September 21, 2015 03: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.

AK Adhikesevan Kothandaraman Syncfusion Team September 22, 2015 07: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.


Live Chat Icon For mobile
Up arrow icon