cvs: peardoc /en/package/structures structures-datagrid.xml /en/package/structures/structures-datagrid examples.xml intro.xml

From: Date: Fri, 10 Sep 2004 14:25:34 +0000
Subject: cvs: peardoc /en/package/structures structures-datagrid.xml /en/package/structures/structures-datagrid examples.xml intro.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-4825@lists.php.net to get a copy of this message
mj Fri Sep 10 10:25:34 2004 EDT Added files: /peardoc/en/package/structures structures-datagrid.xml /peardoc/en/package/structures/structures-datagrid examples.xml intro.xml Log: * Added a bit of documentation for Structures_DataGrid. # Not part of the build yet.

http://cvs.php.net/co.php/peardoc/en/package/structures/structures-datagrid.xml?r=1.1&p=1 Index: peardoc/en/package/structures/structures-datagrid.xml +++ peardoc/en/package/structures/structures-datagrid.xml <?xml version="1.0" encoding="iso-8859-1" ?> <!-- $Revision: 1.1 $ --> <sect1 id="package.structures.structures-datagrid"> <title>Structures_DataGrid</title> <para> This package offers a toolkit to render out a datagrid in HTML format as well as many other formats such as an XML Document, an Excel Spreadsheet, a Smarty Template and more. </para> <para> It also offers paging and sorting functionallity to limit the data that is presented. This concept is based on the .NET Framework <ulink url="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebUIWebControlsDataGridClassTopic.asp">DataGrid control</ulink> and works very well with database and XML result sets. </para> &package.structures.structures-datagrid.intro; &package.structures.structures-datagrid.examples; </sect1> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/peardoc/en/package/structures/structures-datagrid/examples.xml?r=1.1&p=1 Index: peardoc/en/package/structures/structures-datagrid/examples.xml +++ peardoc/en/package/structures/structures-datagrid/examples.xml <?xml version="1.0" encoding="iso-8859-1" ?> <!-- $Revision: 1.1 $ --> <refentry id="package.structures.structures-datagrid.examples"> <refnamediv> <refname>Examples</refname> <refpurpose> Using <classname>Structures_DataGrid</classname> </refpurpose> </refnamediv> <refsect1> <title>Creating Grids</title> <para> The first example creates a simple grid from a PHP array of input data. </para> <example> <title>Simple grid with static input data</title> <programlisting role="php"> <![CDATA[ require_once "Structures/DataGrid.php"; $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')); $dg = new Structures_DataGrid; $dg->bind($rs); // Print the DataGrid $dg->render(); ]]> </programlisting> </example> <para> The table in the example above looks rather ugly, but there are simple methods to change its look &amp; feel. Read on! </para> <para> The following example renders a XHTML table which contains all countries in Europe. The sorting can be changed and the table is split up into single pages with 15 countries per page. The style of the table is adjusted using some table formatting attributes and a bit of <acronym>CSS</acronym>. In contrast to the previous example, the data has been pulled from a <acronym>SQL</acronym> database. </para> <example> <title>Grid with paging, sorting and dynamic data</title> <programlisting role="php"> <![CDATA[ ?> <html> <head> <title>DataGrid: Example</title> <style type="text/css"> table.datagrid {font-family: Verdana, Arial; font-size: x-small; background-color: #333333;} </style> </head> <body> <?php require_once "DB.php"; require_once "Structures/DataGrid.php"; $dbh = DB::Connect("mysql://world@localhost/world"); $dbh->setFetchMode(DB_FETCHMODE_ASSOC); $query = "SELECT Name, Continent FROM Country WHERE Continent = 'Europe'"; $sth = $dbh->query($query); if (isset($_GET['page'])) { $dg = new Structures_DataGrid(15, $_GET['page']); } else { $dg = new Structures_DataGrid(15); } // Define DataGrid Color Attributes $dg->renderer->setTableHeaderAttributes(array('bgcolor' => '#3399FF')); $dg->renderer->setTableOddRowAttributes(array('bgcolor' => '#CCCCCC')); $dg->renderer->setTableEvenRowAttributes(array('bgcolor' => '#EEEEEE')); // Define DataGrid Table Attributes $dg->renderer->setTableAttribute('width', '50%'); $dg->renderer->setTableAttribute('cellspacing', '1'); $dg->renderer->setTableAttribute('cellpadding', '4'); $dg->renderer->setTableAttribute('class', 'datagrid'); // Set empty row table attributes $dg->renderer->allowEmptyRows(true, array('bgcolor' => '#FFFFFF')); // Define columns for the DataGrid $column = new Structures_DataGrid_Column('Name', 'Name', 'Name', array('width' => '75%')); $dg->addColumn($column); $column = new Structures_DataGrid_Column('Continent', 'Continent', 'Continent', array('width' => '75%')); $dg->addColumn($column); // Add rows to the DataGrid while ($sth->fetchInto($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']); } else { $dg->sortRecordSet('Name'); } // Print the DataGrid $dg->render(); echo $dg->renderer->getPaging(); ?> </body> </html> <?php ]]> </programlisting> </example> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/peardoc/en/package/structures/structures-datagrid/intro.xml?r=1.1&p=1 Index: peardoc/en/package/structures/structures-datagrid/intro.xml +++ peardoc/en/package/structures/structures-datagrid/intro.xml <?xml version="1.0" encoding="iso-8859-1" ?> <!-- $Revision: 1.1 $ --> <refentry id="package.structures.structures-datagrid.intro"> <refnamediv> <refname>Introduction</refname> <refpurpose> Renders input data in a table of different formats. </refpurpose> </refnamediv> <refsect1> <title>Description</title> <para> <classname>Structures_DataGrid</classname> is a package with the purpose of rendering input data in a table for a specific output format. Possible output formats are (X)<acronym>HTML</acronym>, <acronym>XML</acronym> or Excel <filename>.xls</filename> files. </para> <para> The input data format is independent of the underlying data storage: It does not matter if the data has been selected from a database, has been harvested from plain text files or converted from a web service call. The data can be sorted and paged, and each cell of the table can have custom output. </para> <note> <title>Example data</title> <para> Some examples in the following sections use data from the <literal>world</literal> database, available on the <ulink url="http://dev.mysql.com/get/Downloads/Manual/world.sql.gz/from/pick">MySQL homepage></ulink>. </para> </note> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
« previous php.pear.doc (#4825) next »