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.

How to make expression column calculate based on the current visible columns

Thread ID:

Created:

Updated:

Platform:

Replies:

52983 Dec 6,2006 01:19 PM Mar 4,2007 10:31 PM Windows Forms 4
loading
Tags: Grouping
James Blibo
Asked On December 6, 2006 01:19 PM


I have a situation like this. I have three columns (A, B, and C) and a expression columns that is defines as A + B + C.

expr-----colA---colB---colC
60 ----- 10 --- 20 --- 30

when the visible columns is colA and colC, I want the expression column to calculate based on only columns A and C like below

expr-----colA---colC
40 ----- 10 --- 30


Is there a way to do this? I am trying to achieve something like the RecordFilter, but only apply that to columns.

Administrator [Syncfusion]
Replied On December 7, 2006 01:11 AM

Hi James,

You can handle the VisibleColumn.Changing event and set the ExpressionDescriptor.Express property to your required expression. Here is a code snippet to show this.

private void VisibleColumns_Changing(object sender, Syncfusion.Collections.ListPropertyChangedEventArgs e)
{
if( e.Action == Syncfusion.Collections.ListPropertyChangedType.Add)
{
ExpressionFieldDescriptor ed = this.gridGroupingControl1.TableDescriptor.ExpressionFields["ExpressionColumn"];
GridVisibleColumnDescriptor column = e.Item as GridVisibleColumnDescriptor;
if( ed.Expression.IndexOf(column.Name) == -1)
{
string sOldValue = string.Format("+ [{0}]",column.Name);
ed.Expression += sOldValue;
}
}
else if( e.Action == Syncfusion.Collections.ListPropertyChangedType.Remove)
{
ExpressionFieldDescriptor ed = this.gridGroupingControl1.TableDescriptor.ExpressionFields["ExpressionColumn"];
GridVisibleColumnDescriptor column = e.Item as GridVisibleColumnDescriptor;
if( ed.Expression.IndexOf(column.Name) != -1)
{
string sOldValue = string.Format("+ [{0}]",column.Name);
string Expression = ed.Expression.Replace(sOldValue,string.Empty);
if( Expression.Equals(ed.Expression) )
{
Expression = ed.Expression.Replace(string.Format("[{0}] +",column.Name),string.Empty);
}
ed.Expression = Expression;
}
}
}

Here is a sample.
GGCExpressionField.zip

Best Regards,
Haneef

James Blibo
Replied On December 7, 2006 01:21 AM

Are you kidding me? I was about to create different permutations of expression fields to accomplish the same thing. You guys are the greatest!

thx

James Blibo
Replied On March 4, 2007 01:47 PM

I have a couple of summary columns above the header. When I toggle (show/hide) soecific visible columns, I expect the summary column above each specific visible columns to also show/hide, depending on which visible columns they're align to; however, this is not happening... what gives?

James Blibo
Replied On March 4, 2007 10:31 PM

got it to work... please disregard post

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.

;