JavaScript Editor Javascript validator     Web page editor 


Structures_DataGrid_Renderer_Flexy -- Flexy Rendering Driver


This driver is experimental and has not been officially released yet. It is only available from CVS.

Supported operations modes

This driver supports the following operation modes:

Table 62-1. Supported operations modes of this driver

Container Supportyes
Output Bufferingyes
Direct Renderingno
Object Preservingno


This driver accepts the following options:

Table 62-2. Options for this driver

OptionTypeDescriptionDefault Value
assocColumnsboolWhether or not to build the column header as an associate array.true
buildFooterboolWhether to build the footer.true
buildHeaderboolWhether to build the header.true
columnAttributesarrayColumn cells attributes. This is an array of the form: array(fieldName => array(attribute => value, ...) ...) This option is only used by XML/HTML based drivers.array()
columnNamesarrayThe set of column names to use for the column header.array()
convertEntitiesboolWhether or not to convert html entities. This calls htmlspecialchars().true
defaultCellValuestringWhat value to put by default into empty cells.null
defaultColumnValuesarrayPer-column default cell value. This is an array of the form: array(fieldName => value, ...).array()
encodingstringThe content encoding. If the mbstring extension is present the default value is set from mb_internal_encoding(), otherwise it is ISO-8859-1.'ISO-8859-1'
evenRowAttributestringThe css class to be used for the even row listings.'even'
excludeVarsarrayVariables to be removed from the generated HTTP queries.array()
extraVarsarrayVariables to be added to the generated HTTP queries.array()
fillWithEmptyRowsboolEnsures that all pages have the same number of rows.false
formatterarrayThe callback array for a column header formatter method.array($this,'defaultHeaderFormatter')
hideColumnLinksarrayBy default sorting links are enabled on all columns. With this option it is possible to disable sorting links on specific columns. This is an array of the form: array(fieldName, ...). This option only affects drivers that support sorting.array()
numberAlignboolWhether to right-align numeric values.true
oddRowAttributestringThe css class to be used for odd row listings.'odd'
onMovestringName of a Javascript function to call on onClick/onSubmit events when the user is either paging or sorting the data. This function receives a single object argument of the form: { page: <page>, sort: [{field: <field>, direction: <direction>}, ...], data: <user_data> }. Remark: setting this option doesn't remove the href attribute, you should return false from your handler function to void it (eg: for AJAX, etc..).null
onMoveDatastringUser data passed in the "data" member of the object argument passed to onMove. No JSON serialization is performed, this is assigned as a raw string to the "data" attribute. It's up to you to add quotes, slashes, etc...''
pagerOptionsarrayThe custom options to be sent to the Pager renderer. 
resultsFormatstringThe format of the results message in sprintf format.'You have %s results in %s pages'
selfPathstringThe complete path for sorting and paging links.$_SERVER['PHP_SELF']
sortingResetsPagingboolWhether sorting HTTP queries reset paging.true

General notes

This driver does not support the render() method, it only is able to be attached setting the container to a current Flexy instance. Options to the renderer must also be passed using the setOptions() method.

Flexy output is buffered using the DataGrid getOutput() method.

This driver assigns the following Flexy template variables: - columnSet: array of columns' labels and sorting links - columnHeader: object of columns' labels and sorting links - recordSet: associate array of records values - numberedSet: numbered array of records values - currentPage: current page (starting from 1) - recordLimit: number of rows per page - pagesNum: number of pages - columnsNum: number of columns - recordsNum: number of records in the current page - totalRecordsNum: total number of records - firstRecord: first record number (starting from 1) - lastRecord: last record number (starting from 1)

This driver also register a Smarty custom function named getPaging that can be called from Smarty templates with {getPaging} in order to print paging links. This function accepts any of the Pager::factory() options as parameters.

Dynamic Template example, featuring sorting and paging:

<!-- Show paging links using the custom getPaging function -->

<p>Showing records {firstRecord} to {lastRecord}
from {totalRecordsNum}, page {currentPage} of {pagesNum}</p>

<table cellspacing="0">
   <!-- Build header -->
               <td><a href="{column[link]:h}">{column[label]:h}</a></td>

   <!-- Build body -->
   <tr class="{getRowCSS()}" flexy:foreach="numberedSet,k,row">

Static Template example, featuring sorting and paging:

<table cellspacing="0">
   <!-- Build header -->
               <a href="{[link]:h}">{columnHeader.field1[label]:h}</a>
              <a href="{columnHeader.surname[link]:h}">{columnHeader.field2[label]:h}</a>

   <!-- Build body -->
   <tr class="{getRowCSS()}" flexy:foreach="recordSet,k,row">

require_once 'HTML/Template/Flexy.php';
require_once 'Structures/DataGrid.php';
require_once 'Structures/DataGrid/Renderer/Flexy.php';

$tpl = new HTML_Template_Flexy($config['HTML_Template_Flexy']);
$dg =& new Structures_DataGrid($_GET['setPerPage'] ? $_GET['setPerPage']
                                                   : 10,$_GET['page']
                                                   ? $_GET['page'] : 1);
$renderer = new Structures_DataGrid_Renderer_Flexy();
echo $dg->getOutput();

JavaScript Editor Javascript validator     Web page editor