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

GridGroupingControl column expression

In GridGroupingControl, In one column, row1''s expression is not the same with row2''s expression. if should custom it,which event i will handle? how to do this? 3ks! e.g: c1 c2 c3 exp1 10 5 2 c1+c2+c3 2 3 2 c1*c2*c3

3 Replies

AD Administrator Syncfusion Team June 17, 2005 04:11 PM

You should create a unbound field and then handle the QueryValue event, e.g. this.gridGroupingControl1.QueryValue += new FieldValueEventHandler(gridGroupingControl1_QueryValue); private void gridGroupingControl1_QueryValue(object sender, FieldValueEventArgs e) { if (e.TableDescriptor.Name == "ReportsTo" && e.Field.Name == "LastNameAndTitle") { // "[LastName] + ''('' + [Title] + '')''")); e.Value = String.Format("{0} ({1})", e.Record.GetValue("LastName"), e.Record.GetValue("Title")); } } Stefan >In GridGroupingControl, >In one column, row1''s expression is not the same with row2''s expression. >if should custom it,which event i will handle? > >how to do this? >3ks! >e.g: > >c1 c2 c3 exp1 >10 5 2 c1+c2+c3 >2 3 2 c1*c2*c3 >


AD Administrator Syncfusion Team June 19, 2005 08:56 PM

hi,stefan, If i want to calc (row1/row2) in QueryValue, how can i do? in my App,some row''s unbound filed is column expression,but some row is row calculation: e.g: col1 col2 exp1 10 5 col1+col2 2 3 col1+col2 10/2 5/3 (col1+col2)/(col1+col2) if using QueryValue,how can i do? >You should create a unbound field and then handle the QueryValue event, e.g. > > > this.gridGroupingControl1.QueryValue += new FieldValueEventHandler(gridGroupingControl1_QueryValue); > > > private void gridGroupingControl1_QueryValue(object sender, FieldValueEventArgs e) > { > if (e.TableDescriptor.Name == "ReportsTo" && e.Field.Name == "LastNameAndTitle") > { > // "[LastName] + ''('' + [Title] + '')''")); > e.Value = String.Format("{0} ({1})", e.Record.GetValue("LastName"), e.Record.GetValue("Title")); > } > } > > >Stefan >>In GridGroupingControl, >>In one column, row1''s expression is not the same with row2''s expression. >>if should custom it,which event i will handle? >> >>how to do this? >>3ks! >>e.g: >> >>c1 c2 c3 exp1 >>10 5 2 c1+c2+c3 >>2 3 2 c1*c2*c3 >>


AD Administrator Syncfusion Team June 20, 2005 05:10 AM

You will have to write the code to retrieve whatever data you want to use in the calculation. Here is a handler that, for every third item in the column, divides the sum of the previous 2 items.
private void gridGroupingControl1_QueryValue(object sender, FieldValueEventArgs e)
{
	int row = e.Record.ParentChildTable.Records.IndexOf(e.Record);
	if(row > 1 && (row+1) % 3 == 0)
	{
		GridRecord rec1 = e.Record.ParentChildTable.Records[row-1] as GridRecord;
		GridRecord rec2 = e.Record.ParentChildTable.Records[row-2] as GridRecord;
		e.Value = (double) rec2.GetValue("exp") / (double)rec1.GetValue("exp");
	}
	else
	{
		e.Value = (double)((int)e.Record.GetValue("Col1") + (int)e.Record.GetValue("Col2"));
	}
}

            

Loader.
Live Chat Icon For mobile
Up arrow icon