Source for file ScGrids.php
Documentation is available at ScGrids.php
* An open source SmartClient View Helper for Zend Framework
* @author Fernando Marcelo Morgenstern <fernando@consultorpc.com>
* @copyright Copyright (c) 2009, ConsultorPC
* @license http://www.gnu.org/licenses/lgpl-3.0-standalone.html
* @link http://smartclientphp.com/
* Smart Client Grids Helper
* @uses viewHelper SmartClient
* @var Zend_View_Interface
* @param $view Zend_View_Interface
public function setView( Zend_View_Interface $view )
* @param mixed $data If string, it must be the id of the field. If array, them we will loop on it
* @param string $title Title of the field
* @param array $options Additional options
public function addField( $data , $title = '' , $options = '' )
// Check if it is an array
// Add name and title to the new field
$newField['name'] = $data;
$newField['title'] = $title;
// Check if options is array and do the loop
foreach ( $options as $name => $value )
$newField[$name] = $value;
// TODO: Check if at least name and title are set on the new field
// Add field to the array
* Get an array and do a loop using the addField function
* @param array $data Array containing multiple fields
foreach ( $data as $row )
* Return the current fields array
* Create the Smart Client grid
* @param mixed $data If string, it must be the id of the field. If array, them we will loop on it
public function create( $data , $dataSource = '' , $width = '' , $height = '' , $options = '' )
// Check if we have an array
// Add vars to the new grid
$newGrid['width'] = $width;
$newGrid['height'] = $height;
$newGrid['fields'] = $this->_fields;
// Add remove quotes str, to avoid datasource being quoted
$newGrid['dataSource'] = $this->addQuotesStr( $dataSource );
// Set default value for autoFetchData if it is not set
if ( empty( $options['autoFetchData'] ) )
$options['autoFetchData'] = true;
// Check if options is array and do the loop
foreach ( $options as $name => $value )
$newGrid[$name] = $value;
$dataEncoded = Zend_Json::encode( $newGrid );
// Remove vars that shouldn't be quoted
<script type="text/javascript">
|