This method allows you to bind your data set to the DataGrid. You can bind
any data type that is supported with a DataSource driver. If you have a
data type that is not supported, you can easily create your own driver by
mimicing the parent class or one of the existing drivers or post a message
to the mailing lists to see if someone can help you with it. If you write
your own, please post it back to the community for anyone else who might be
interested in using it.
Parameter
mixed
$data
The record set in any of the supported data source types
(i.e. DB_DataObject, DB_Result, XML, RSS, CSV, Array)
array
$options
Optional. An array of options to be used, these are respective to the driver.
string
$type
Optional. This is used if the data source type cannot be detected.
Return value
mixed - TRUE upon success otherwise a PEAR_Error upon failure
$dg =& new Structures_DataGrid(20);
$person = new DataObjects_Person;
$person->hair = 'red';
$person->has_glasses = 1;
// The datagrid will bind the dataobject and only select the first 20 records
$dg->bind($person);
$dg->render();
$dg =& new Structures_DataGrid(20);
$result = $db->query("SELECT * FROM person WHERE hair='red' AND has_glasses=1");
// The datagrid will bind the db_result object and only show the first 20 records
// This is not the most optimal way, because the datagrid will load all of the
// records and then limit down to 20, but will allow for paging.
$dg->bind($result);
$dg->render();
$dg =& new Structures_DataGrid();
$result = $db->query("SELECT * FROM person WHERE hair='red' AND has_glasses=1 LIMIT 20");
// The datagrid will bind the db_result object and show all of the first 20 records
// In order to use paging, you must use a seperate Pager object.
$dg->bind($result);
$dg->render();