HomeActive Query BuilderAutomatic Alias

Automatic Alias

Is there anyway to have Aliases assigned when there is either a duplicate field or an expression is entered? It seems this has to be done manually now.

For example say I have the following expression:
Column1 * Column2
I would like this to get an automatic alias such as Exp1.

Also if a column is used more then once in the output.
Joe | email
March 9 2009, 09:00 PM
Dear Joe,

You may use the DatasourceFieldAdded and GridCellValueChanged events (available in the VCL and .NET Editions) to create aliases for expressions.

Use the DatasourceFieldAdded event to check for duplicate fields: you may set an alias by assigning it to the criteriaItem.AliasString (ASelectItem.AliasString for VCL) property. Use the criteriaItem.CriteriaList (ASelectItem.SelectList for VCL) to get access to the list of all expressions of the current sub-query.

Use the GridCellValueChanged event to check for custom expressions. An expression is not a single field when criteriaItem.ExpressionField (ASelectItem.ExpressionField for VCL) property is Null.
Sergey Smagin | email
1 day, 4 hours since original post
Hi Sergey,

I didn't have those events in my version (1.3). I upgraded to the latest and now it works perfect. Thanks.

One more questions - Is there a simple way to tell if a criteriaItem is an output column or not?

Joe | email
1 day, 12 hours since original post
Use the criteriaItem.Select property.
Sergey Smagin | email
1 day, 16 hours since original post
This topic is closed