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.
Order(<Att1>, <Att2>, ...., <AttN>);
Objects: Web Panel, Work With, Panel
Generators: .NET Framework, .NET, Java, Apple, Android, Angular
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.
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.
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.
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.
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.
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.
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:
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.
Order clause
Order property