cvs: pear /Structures_DataGrid/DataGrid/Docs/Examples example-smarty.php

From: Date: Fri, 22 Oct 2004 15:37:42 +0000
Subject: cvs: pear /Structures_DataGrid/DataGrid/Docs/Examples example-smarty.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-25065@lists.php.net to get a copy of this message
asnagy Fri Oct 22 11:37:42 2004 EDT Added files: /pear/Structures_DataGrid/DataGrid/Docs/Examples example-smarty.php Log: Intial checkin http://cvs.php.net/co.php/pear/Structures_DataGrid/DataGrid/Docs/Examples/example-smarty.php?r=1.1&p=1 Index: pear/Structures_DataGrid/DataGrid/Docs/Examples/example-smarty.php +++ pear/Structures_DataGrid/DataGrid/Docs/Examples/example-smarty.php <?php require_once('Structures/DataGrid.php'); // Data to be printed by DataGrid $rs = array(array('id' => 1, 'first_name' => 'Bob', 'last_name' => 'Smith', 'age' => '37'), array('id' => 2, 'first_name' => 'John', 'last_name' => 'Doe', 'age' => '23'), array('id' => 3, 'first_name' => 'Fred', 'last_name' => 'Thompson', 'age' => '58'), array('id' => 4, 'first_name' => 'Sally', 'last_name' => 'Robinson', 'age' => '52'), array('id' => 5, 'first_name' => 'Robert', 'last_name' => 'Brown', 'age' => '19')); // Define New DataGrid with a limit of 3 records if (isset($_GET['page'])) { $dg = new Structures_DataGrid(3, $_GET['page'], DATAGRID_RENDER_SMARTY); } else { $dg = new Structures_DataGrid(3, null, DATAGRID_RENDER_SMARTY); } // Define columns for the DataGrid $column = new Structures_DataGrid_Column('Name', 'first_name', 'first_name', array('width' => '75%')); $dg->addColumn($column); $column = new Structures_DataGrid_Column('Age', 'age', 'age', array('width' => '25%')); $dg->addColumn($column); $column = new Structures_DataGrid_Column('Edit', null, null, array('align' => 'center')); $dg->addColumn($column); $column = new Structures_DataGrid_Column('Delete', null, null, array('align' => 'center'), 'delete'); $dg->addColumn($column); // Add rows to the DataGrid foreach ($rs as $row) { $row = new Structures_DataGrid_Record($row); $result = $dg->addRecord($row); if (PEAR::isError($result)) { echo $result->getMessage(); } } // Sort the array based on the field if (isset($_GET['orderBy'])) { $dg->sortRecordSet($_GET['orderBy'], $_GET['direction']); } // Print the DataGrid $result = $dg->renderer->setTemplate('example.tpl'); if (PEAR::isError($result)) { echo $result->getMessage(); } else { $dg->render(); } ?>

« previous php.pear.cvs (#25065) next »