cvs: peardoc /en/package/structures/structures-datagrid example-advanced.xml
| From: | Olivier Guilyardi | Date: | Fri, 21 Apr 2006 16:43:13 +0000 |
| Subject: | cvs: peardoc /en/package/structures/structures-datagrid example-advanced.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-7808@lists.php.net to get a copy of this message | ||
olivierg Fri Apr 21 16:43:13 2006 UTC
Modified files:
/peardoc/en/package/structures/structures-datagrid
example-advanced.xml
Log:
Updated to better practices
http://cvs.php.net/viewcvs.cgi/peardoc/en/package/structures/structures-datagrid/example-advanced.xml?r1=1.15&r2=1.16&diff_format=u
Index: peardoc/en/package/structures/structures-datagrid/example-advanced.xml
diff -u peardoc/en/package/structures/structures-datagrid/example-advanced.xml:1.15
peardoc/en/package/structures/structures-datagrid/example-advanced.xml:1.16
--- peardoc/en/package/structures/structures-datagrid/example-advanced.xml:1.15 Tue Feb 28 11:36:59
2006
+++ peardoc/en/package/structures/structures-datagrid/example-advanced.xml Fri Apr 21 16:43:13 2006
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1" ?>
-<!-- $Revision: 1.15 $ -->
+<!-- $Revision: 1.16 $ -->
<refentry id="package.structures.structures-datagrid.example-advanced">
<refnamediv>
@@ -26,17 +26,17 @@
require 'Structures/DataGrid.php';
require 'myclasses/User.php';
-// Determine sort order and direction as well as the page to display
-$orderBy = isset($_GET['orderBy']) ? $_GET['orderBy'] : 'lname';
-$dir = isset($_GET['direction']) ? $_GET['direction'] : 'ASC';
-
-// Define the Data Source for the DataGrid
+// Instantiate the DataObject ; that's our DataSource container
$user = new User_DataObject();
-// Create the DataGrid, bind it's Data Source and define it's columns
+// Create the DataGrid, and bind the DataSource container
$dg =& new Structures_DataGrid(20); // Display 20 per page
-$dg->sortRecordSet($orderBy, $dir);
$dg->bind($user);
+
+// Specify how the DataGrid should be sorted by default
+$dg->setDefaultSort(array('lname' => 'ASC'));
+
+// Define columns
$dg->addColumn(new Structures_DataGrid_Column(null, null, null, array('width' =>
'10'), null, 'printCheckbox()'));
$dg->addColumn(new Structures_DataGrid_Column('Name', null, 'lname',
array('width' => '40%'), null, 'printFullName()'));
$dg->addColumn(new Structures_DataGrid_Column('Username', 'username',
'username', array('width' => '20%')));
@@ -64,12 +64,12 @@
'sortIconDESC' => '⇓'
);
-// Create a table
+// Create a HTML_Table
$table = new HTML_Table($tableAttribs);
$tableHeader =& $table->getHeader();
$tableBody =& $table->getBody();
-// Pass the table instance to the DataGrid and set the options
+// Ask the DataGrid to fill the HTML_Table with data, using rendering options
$dg->fill($table, $rendererOptions);
// Set attributes for the header row
@@ -80,8 +80,9 @@
// Output table and paging links
echo $table->toHtml();
-$renderer =& $dg->getRenderer();
-echo $renderer->getPaging();
+
+// Display paging links
+$datagrid->render(DATAGRID_RENDER_PAGER);
function printCheckbox($params)
{