Curl Global Community
Page 6: Structure of a Program that Sorts and Filters the Data - Printable Version

+- Curl Global Community (https://communities.curl.com)
+-- Forum: Tutorials (https://communities.curl.com/forumdisplay.php?fid=3)
+--- Forum: Public Training (https://communities.curl.com/forumdisplay.php?fid=4)
+---- Forum: Curl IDE Made Easy (https://communities.curl.com/forumdisplay.php?fid=6)
+----- Forum: Try 3: Displaying Data in a Grid (https://communities.curl.com/forumdisplay.php?fid=11)
+----- Thread: Page 6: Structure of a Program that Sorts and Filters the Data (/showthread.php?tid=60)



Page 6: Structure of a Program that Sorts and Filters the Data - ashimo - 06-16-2011

Structure of a Program that Sorts and Filters the Data

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.