Quantcast
Channel: Developer Express Inc.
Viewing all articles
Browse latest Browse all 2370

Reporting — New Expression Functions (v24.1)

$
0
0

As you may already know, DevExpress Reports offers an adapted layout option that allows you arrange, shape, and organize data in the most appropriate manner. One such data shaping option is grouping. You can arrange data in nested and multi-field groups within the detail band of a table report. In our v24.1 release cycle, we introduced several functions that allow you to obtain indexes for different group elements. These new functions include:

  • CurrentRowIndexInGroup()— returns the current row’s index within the group.
  • GroupIndex(level)— locates the parent group row at the specified nesting level and returns that row’s index.
  • NextRowColumnValue(columnName)— obtains the next row and returns the value from the specified column.
  • PrevRowColumnValue(columnName)— obtains the previous row and returns the value from the specified column.
  • In this blog post, I'll detail a few usage scenarios and illustrate how you can obtain/manage different group elements with the functions listed above.

    Group Numbering by Index

    In this usage scenario, I'll build a report that displays a multi-level numbered list. To achieve this, my report controls will use GroupIndex() and CurrentRowIndexInGroup() functions in their data binding expressions (to return group and row indexes).

    Table cells specify the following data binding expressions:

    “Category Name” group:

  • GroupIndex(1) + 1— displays indexes of root-level groups.
  • “Discontinued” group:

  • GroupIndex(1) + 1 + '.' + (GroupIndex(0) + 1)— adds second-level group indexes.
  • The detail band:

  • GroupIndex(1) + 1 + '.' + (GroupIndex(0) + 1) + '.' + (CurrentRowIndexInGroup(0) + 1)— adds row indexes.
  • Output: A report that groups products by category and discontinued state:

    Change the Appearance of Individual Groups

    In this usage scenario, I'll apply different styles to groups in the table to distinguish groups when associated group headers are empty.

    The table's StyleName property is bound to the following expression:

    Iif(GroupIndex(0) %2 == 0, 'DetailData1', 'DetailData3_Odd')

    Output: Different styles are applied to odd and even groups:

    Locate the Last Row in a Group

    In this example, I use an expression to highlight the product with the lowest statewide sales (compared to expected sales).

    The table's Font.Bold property is bound to the following expression:

    Iif(NextRowColumnValue('Product')!= [Product] OR [DataSource.IsLastRow], True, False)

    As you can see below, the expression locates the last row in the group and applies a bold style to it (the StylePriority.UseFont property is set to false):


    As always, we welcome your feedback. Should you have questions about the examples used in this post, feel free to submit a support ticket via the DevExpress Support Center.


    Viewing all articles
    Browse latest Browse all 2370

    Trending Articles