Structures_DataGrid_Renderer_Flexy

Structures_DataGrid_Renderer_Flexy – Flexy Rendering Driver

Availability

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

Supported operations modes

This driver supports the following operation modes:

Supported operations modes of this driver
Mode Supported?
Container Support yes
Output Buffering yes
Direct Rendering no
Streaming no
Object Preserving no

Options

This driver accepts the following options:

Options for this driver
Option Type Description Default Value
assocColumns bool Whether or not to build the column header as an associate array. true
buildFooter bool Whether to build the footer. true
buildHeader bool Whether to build the header. true
columnAttributes array Column 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()
columnNames array The set of column names to use for the column header. array()
convertEntities bool Whether or not to convert html entities. This calls htmlspecialchars(). true
defaultCellValue string What value to put by default into empty cells. null
defaultColumnValues array Per-column default cell value. This is an array of the form: array(fieldName => value, ...). array()
encoding string The 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'
evenRowAttribute string The css class to be used for the even row listings. 'even'
excludeVars array Variables to be removed from the generated HTTP queries. array()
extraVars array Variables to be added to the generated HTTP queries. array()
fillWithEmptyRows bool Ensures that all pages have the same number of rows. false
formatter array The callback array for a column header formatter method. array($this,'defaultHeaderFormatter')
hideColumnLinks array By 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()
numberAlign bool Whether to right-align numeric values. true
oddRowAttribute string The css class to be used for odd row listings. 'odd'
onMove string Name 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
onMoveData string User 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... ''
pagerOptions array The custom options to be sent to the Pager renderer.  
resultsFormat string The format of the results message in sprintf format. 'You have %s results in %s pages'
selfPath string The complete path for sorting and paging links. $_SERVER['PHP_SELF']
sortingResetsPaging bool Whether 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 -->
{getPaging():h}

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

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

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

Static Template example, featuring sorting and paging:

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

   <!-- Build body -->
   <tr class="{getRowCSS()}" flexy:foreach="recordSet,k,row">
       <td>{row[field1]}</td>
       <td>{row[field2]}</td>
   </tr>
</table>

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);
$dg->bind($dataObject);
$renderer = new Structures_DataGrid_Renderer_Flexy();
$renderer->setContainer($tpl);
$renderer->setOptions($config['Structures_DataGrid']);
$dg->attachRenderer($renderer);
$this->tpl->compile($template);
echo $dg->getOutput();
CSV Rendering Driver (Previous) HTML form to edit a record (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.