Flash CS3 Documentation |
|||
| ActionScript 2.0 Components Language Reference > DataSet component > DataSet.useSort() | |||
Flash Player 7.
Flash MX Professional 2004.
dataSetInstance.useSort(sortName, order)
sortName A string that contains the name of the sort to use.
order An integer value that indicates the sort order for the sort; the value must be DataSetIterator.Ascending or DataSetIterator.Descending.
Nothing.
Method; switches the sort for the current iterator to the one specified by sortName, if it exists. If the specified sort does not exist, a DataSetError exception is thrown.
To create a sort, use DataSet.addSort().
The following example uses DataSet.hasSort() to determine if a sort named "customer" exists. If it does, the code calls DataSet.useSort() to make "customer" the current sort. Otherwise, the code creates a sort by that name using DataSet.addSort().
if (my_ds.hasSort("customer")) {
my_ds.useSort("customer");
} else {
my_ds.addSort("customer", ["customer"], DataSetIterator.Descending);
}
DataSet.applyUpdates(), DataSet.hasSort()
Flash CS3