06-16-2011, 04:32 PM
Structure of a Program that Sorts and Filters the Data
The RecordGrid data can be sorted and filtered.
1. Sorting data: sort
We can use sort to sort the data displayed by RecordGrid. To do so, we specify the names of the fields to be sorted as character strings. As in this example, when we want to sort the data into descending order, we add DESC after each field name. We can specify multiple fields by delimiting their names with a comma (,).
By using RecordSort, we can specify more complex types of sorting.
2. Filtering data: filter
To filter the data to be displayed, we use the filter field. To specify the fields and data to be filtered, we use RecordData. Using RecordFilter, we can specify relatively complex filtering. If we specify null, then no filtering is performed.
3. Fixing the display region: set-frozen-region
Using set-frozen-region, we can fix the position of the RecordGrid window frame. This prevents the scrolling of the specified lines and columns. There are several other APIs for managing fixed lines and columns. These are described in the Curl API documentation.
4. Displaying the layout: VBox
As explained above, the final expression specified in the value block is displayed on the screen. In the current example, this VBox is the final expression. Therefore, the screen layout will appear as shown in the figure.
The RecordGrid data can be sorted and filtered.
1. Sorting data: sort
Code:
set rg.sort = score DESC
We can use sort to sort the data displayed by RecordGrid. To do so, we specify the names of the fields to be sorted as character strings. As in this example, when we want to sort the data into descending order, we add DESC after each field name. We can specify multiple fields by delimiting their names with a comma (,).
Code:
set rg.sort = score DESC, age DESC
By using RecordSort, we can specify more complex types of sorting.
2. Filtering data: filter
Code:
set rg.filter = {RecordData city = Miami}
To filter the data to be displayed, we use the filter field. To specify the fields and data to be filtered, we use RecordData. Using RecordFilter, we can specify relatively complex filtering. If we specify null, then no filtering is performed.
3. Fixing the display region: set-frozen-region
Code:
{rg.set-frozen-region 0,1}
Using set-frozen-region, we can fix the position of the RecordGrid window frame. This prevents the scrolling of the specified lines and columns. There are several other APIs for managing fixed lines and columns. These are described in the Curl API documentation.
4. Displaying the layout: VBox
Code:
{VBox
rg,
{HBox
sort-button,
filter-button,
reverse-button
}
}
As explained above, the final expression specified in the value block is displayed on the screen. In the current example, this VBox is the final expression. Therefore, the screen layout will appear as shown in the figure.