PEAR Manual
Prev |  | Next

# Structures_DataGrid::sortRecordSet()

Structures_DataGrid::sortRecordSet() -- Sorts the record set based on a column

## Synopsis

``sortRecordSet` (string $sortBy, string $direction)`

## Description

This method allows you to sort the data set that is in the datagrid. If you are using a datasource object such as DB_DataObject, it will attempt to run the relevent sort method. Otherwise it will sort the array using PHP's multisort function.

## Parameter

string `$sortBy`

  The column to sort the data set by

string `$direction`

  The direction to sort. The only values available are 'ASC' for an ascending sort or 'DESC' for a descending sort.

## Note

For the DataSource drivers Array, CSV, RSS and XML sortRecordSet() needs to be called after bind().

For all other DataSource drivers like DataObject, DB, DBQuery, DBTable sortRecordSet() needs to be called after before bind().

## Example

Example 55-1. Sorting a record set.
    <?php
    require_once 'Structures/DataGrid.php';

    $dg =& new Structures_DataGrid();

    // ... get my data and bind it to the $dg ...

    $dg->sortRecordSet('lname', 'ASC');

    $dg->render();
    ?>

Prev | Home | Next
Structures_DataGrid::render() | Up | Structures_DataGrid_Column