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

4 posts, 1 answers
  1. Pooya
    Pooya avatar
    107 posts
    Member since:
    Apr 2011

    Posted 22 Sep 2011 Link to this post

    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,

  2. Answer
    Veli
    Admin
    Veli avatar
    2002 posts

    Posted 27 Sep 2011 Link to this post

    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
  3. Pooya
    Pooya avatar
    107 posts
    Member since:
    Apr 2011

    Posted 29 Sep 2011 Link to this post

    Thanks Veli.
  4. Vinh
    Vinh avatar
    1 posts
    Member since:
    May 2015

    Posted 04 Jun 2018 in reply to Veli Link to this post

    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>

Back to Top