Official Content

In the case of Panels, it establishes the order for the implicit navigation associated with the fixed part.
In the case of Web Panels, it establishes the order for the implicit navigation associated with the fixed part when the object has no Grids. If the Web Panel contains at most one Grid, the Order rule establishes the order for the implicit navigation associated with the Grid. 
If there is more than one Grid (either in a Panel or a Web Panel), use each Grid's Order property.

Syntax

Order(<Att1>, <Att2>, ...., <AttN>);

Scope

Objects: Web PanelWork WithPanel
Generators: .NET Framework, .NET, JavaAppleAndroidAngular

Description

The Order rule applies to implicit navigations; that is to say, in those cases where you do not write a For Each command and GeneXus determines a navigation. Since you do not write a For each command with its corresponding Order clause, you can indicate the desired order to navigate and retrieve the scanned records using the Order rule.

Using the Order rule in a Panel

For Panels, the Order rule only applies to the fixed part, not to the Grids within the Panel. This is because the fixed part has its own Base Table, which is separate from the Base Tables of the Grids.

Using the Order rule in a Web Panel without Grids

In this case, consider that only one record is displayed. The Order rule can be useful, for example, if you need to display the first or last record of a set based on a specific order.

Using the Order rule in a Web Panel with one Grid

When the Order rule is defined in a Web Panel with one Grid it applies to the Grid navigation. You can also achieve the same result by setting the Grid's Order property.

If there is more than one Grid, use each Grid's Order property.

General behavior for all cases

If you don't specify an order using this rule nor the Order property for a Grid, GeneXus will use the base table's primary key to order the records. This is the same behavior as in a For Each command.

To indicate a descending order for an attribute, enclose its name in brackets ( ).

When defining compound orders, you can include some attributes in ascending order and other attributes in descending order within the same Order rule.

Samples

Sample 1

Consider the following Transaction object called “Customer”:

Customer
{
    CustomerId*
    CustomerName
    CustomerAddress
    CustomerPhone
}

Suppose you define a Web Panel object with a Grid containing the Customer attributes.  

OrderRule_2024124164345_1_png

The Grid's base table is Customer; by default, the Customer records will be retrieved and sorted by their CustomerId.

If you need to display the customers sorted by name in ascending order, you can define a rule in the Rules tab of the Web Panel as follows:

Order(CustomerName);

At runtime, the Web Panel will look as shown below:

OrderRule1_2024124164319_1_png

Note: The same behavior can be obtained by setting the Grid's Order property to CustomerName.

Sample 2

Given the following Transaction objects:

Supplier
{
    SupplierId*
    SupplierName
}
Invoice
{
    InvoiceId*
    InvoiceDate
    SupplierId
    SupplierName
    ......
}

Suppose you need to define a Web Panel that displays the invoice records in the Grid sorted by an order consisting of InvoiceDate in descending order and SupplierName in ascending order. In that case, you can define a rule in the Rules tab of the Web Panel as follows:

Order((InvoiceDate), SupplierName);

Note: The same behavior can be obtained by setting the Grid's Order property to (InvoiceDate), SupplierName.

See Also

Order clause
Order property

Last update: December 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant