This is a migrated thread and some comments may be shown as answers.

GridCalculatedColumn has a Property called “Expression”, what can it contain?

3 Answers 250 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pooya
Top achievements
Rank 1
Pooya asked on 22 Sep 2011, 03:04 PM

GridCalculatedColumn has a Property called "Expression", what could it contain?

These are valid:

iif(condition, trueResult, falseResult)
{0}*{1}
Convert.ToString({0})

How to format the result of the expression?

e.g. this doesn't work:

iif(condition, String.Format"{0:0.00}%", {0}), "NA")

This Expression doesn't seem to be the same as the .NET Data Column Expression either as I tested it and at least the Len and Convert methods are not supported.

Please help.

Thanks,

3 Answers, 1 is accepted

Sort by
0
Accepted
Veli
Telerik team
answered on 27 Sep 2011, 11:52 AM
Hi Pooya,

The GridCalculatedColumn.Expression property is fully compatible with the Data Column Expression syntax when you set RadGrid.EnableLinqExpressions = false. By default, RadGrid uses dynamic LINQ expressions for many data-related operations. The EnableLinqExpressions is true by default. With this property enabled, GridCalculatedColumn.Expression supports the Dynamic LINQ syntax. When you disable LINQ expressions, you can use the DataColumn.Expression syntax.

Greetings,
Veli
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Pooya
Top achievements
Rank 1
answered on 29 Sep 2011, 05:27 PM
Thanks Veli.
0
Vinh
Top achievements
Rank 1
answered on 04 Jun 2018, 08:15 AM

Can you give me a examples? With use EnableLinqExpressions="false", I lost my filtering work flow.

With this code, how do you change to dynamic linq? This code just works with EnableLinqExpressions = "false", but I want to set EnableLinqExpressions  = true for my purpose.

<telerik:GridCalculatedColumn AllowFiltering="false" UniqueName="Balance" Exportable="false" HeaderText="Balance"
                            DataFields="ContractValue, TotalPaid" Expression=' {0} - {1}'  DataFormatString="{0:c}" DataType="System.Decimal"  Aggregate="Sum" AutoPostBackOnFilter="true" >
                            <FooterStyle HorizontalAlign="Right" Font-Bold="true" />
                            <ItemStyle HorizontalAlign="Right" />
                        </telerik:GridCalculatedColumn>

Tags
Grid
Asked by
Pooya
Top achievements
Rank 1
Answers by
Veli
Telerik team
Pooya
Top achievements
Rank 1
Vinh
Top achievements
Rank 1
Share this question
or