sort

Sort the current Datawindow

Generate an error, if sort string not correct

Return always true

 

A DataWindow object can have sort criteria specified as part of its definition. sort("") overrides the definition, providing new sort criteria for the DataWindow. However, it use the defined sort argument directly

The sort criteria for a column have one of the forms shown in the following table, depending on whether you specify the column by name or number.

 

Examples for specifying sort order

Syntax for sort order

Examples

columnname order

dw_1.sort("emp_lname A");
dw_1.sort("emp_lname asc, dept_id desc");

columnnumber order

dw_1.sort("#3 A");

 

It's possible to work with datawindow expression

The following table shows the recognized values for order. These values are case insensitive. For example, as, s, AS, or all specify a case-sensitive sort in ascending order.

 

Recognized values for sort order

Order value

Resulting sort order

a, asc, ascending, ai, i

Case-insensitive ascending

d, desc, descending, di

Case-insensitive descending

as, s

Case-sensitive ascending

ds

Case-sensitive descending

 

If you omit order or specify an unrecognized string, the sort is performed in ascending order and is case insensitive. You can specify secondary sorting by specifying criteria for additional columns in the format string. Separate each column specification with a comma.

 

To let the user specify the sort criteria for a DataWindow control, you can pass the function without parameter. Beas  displays the Specify Sort Columns dialog with the sort specifications blank. Then you can call Sort to apply the users criteria.
dw_setsort

 

Events

Follow events called (x=1-7):

dw_x_rowfocuschanged();
dw_x_sortchanged();

Note: don't change the order/filter inside this event!

 

Examples

 

Example 1

This statement sets the sort criteria for dw_1 so emp_status is sorted in ascending order and within each employee status, emp_salary is sorted in descending order:

 

dw_1.sort("emp_status asc, emp_salary desc");

 

Example 2

If emp_status is column 1 and emp_salary is column 5 in dw_1, then the following statement is equivalent to the sort specification above:

dw_1.sort("#1 A, #5 D");

 

Example 3

This example defines sort criteria to sort the status column in ascending order and the salary column in descending order within status. Both sorts are case sensitive. After assigning the sort criteria to the DataWindow control dw_emp, it sorts dw_1:

let newsort = "emp_status as, emp_salary ds";
dw_1.sort(newsort);

 

Example 4

The following example sets the sort criteria for dw_1 without arguments, causing Beas to display the Specify Sort Columns dialog so that the user can specify sort criteria. The Sort method applies the criteria the user specifies:

dw_1.sort();