
Zend_Grid
{zone-data}
{zone-data:proposer-list}
[Bento Vilas Boas|mailto:geral@petala-azul.com]
{zone-data}
{zone-data:liaison}
TBD
{zone-data}
{zone-data:revision}
1.0 - 26 June 2010: Initial Draft.
{zone-data}
{zone-data:overview}
Zend_Grid is a component for display/manage data with source abstraction. Although it can be used anywhere in your application, it has a comprehensive feature list that fits the needs for an administrative grid where we need to easily display and edit data, create reports and even create WebServices to access information.
{zone-data}
{zone-data:references}
* Community
{zone-data}
{zone-data:requirements}
Must Support:
* Zend_Config
* Multiples sources
* CRUD operations with bulk add/edit/remove options and auto-validation from tables definition
* PRG Form Processing
* Templates
* Multiples renders (Table, PDF, Print, Xml, Excel, etc, etc)
* Extra columns
* Extra rows
* Aggregate Expressions
* Horizontal splitting of records
* Multiple instances per page
* Custom Filters
* Auto-filters based on field definition (enum, set, etc, etc)
* Mass actions
* Cache
* Content format plugins
* Ajax
* Conditional Field Rendering
* Render specific parts of grid
* Sorting results
* Auto-paging. Change number of results per page
* Save params in session (Filters, Order, Page, Records per page)
* Detailed view of records
* Internationalization
* Decorators
* Callbacks
* Routing
{zone-data}
{zone-data:dependencies}
* Zend_View
* Zend_Config
* Zend_Form
* Zend_Session
* Zend_Controller
* Zend_Registry
* Zend_Cache
* Zend_Exception
{zone-data}
{zone-data:operation}
* User instantiates Zend_Grid
* Deploy class is loaded
* User config is applied, after merged with global config
* User defines a data source
* User calls deploy after setting all params they want
* Zend_Grid builds additional source params like where, limit, order...
* Data is fetched from source
* Data is converted to an array
* User options are applied to data (decorators, callbacks, helpers, )
* Information presented to user in desired format
{zone-data}
{zone-data:milestones}
Milestone 1: [DONE] Working prototype written and tested. [Demos|http://zfdatagrid.com]
Milestone 2: [DONE] Create initial documentation. [Project Code|http://code.google.com/p/zfdatagrid/]
Milestone 3: [DONE] Working code checked into SVN.Units in progress.
Milestone 4: [DONE] Submitted to Ready for Review.
{zone-data}
{zone-data:class-list}
* Zend_Grid
* Zend_Grid_Column
* Zend_Grid_Deploy_Csv
* Zend_Grid_Deploy_DeployInterface
* Zend_Grid_Deploy_Jqgrid
* Zend_Grid_Deploy_Json
* Zend_Grid_Deploy_Ods
* Zend_Grid_Deploy_Odt
* Zend_Grid_Deploy_Ofc
* Zend_Grid_Deploy_Pdf
* Zend_Grid_Deploy_Print
* Zend_Grid_Deploy_Table
* Zend_Grid_Deploy_Word
* Zend_Grid_Deploy_Wordx
* Zend_Grid_Deploy_Xml
* Zend_Grid_Exception
* Zend_Grid_Extra_Column
* Zend_Grid_Extra_Row
* Zend_Grid_Filters_Render_Date
* Zend_Grid_Filters_Render_Number
* Zend_Grid_Filters_Render_RenderAbstract
* Zend_Grid_Filters_Render_RenderInterface
* Zend_Grid_Filters_Render_Select
* Zend_Grid_Filters_Render_Text
* Zend_Grid_Filters
* Zend_Grid_Form
* Zend_Grid_Formatter_Array
* Zend_Grid_Formatter_Currency
* Zend_Grid_Formatter_Date
* Zend_Grid_Formatter_FormatterInterface
* Zend_Grid_Formatter_Image
* Zend_Grid_GridInterface
* Zend_Grid_Source_Array
* Zend_Grid_Source_Csv
* Zend_Grid_Source_Db_DbAbstract
* Zend_Grid_Source_Doctrine
* Zend_Grid_Source_Json
* Zend_Grid_Source_SourceInterface
* Zend_Grid_Source_Xml
* Zend_Grid_Source_Zend_Select
* Zend_Grid_Source_Zend_Table
* Zend_Grid_Template_Ods_Ods
* Zend_Grid_Template_Odt_Odt
* Zend_Grid_Template_Print_Print
* Zend_Grid_Template_Table_Table
* Zend_Grid_Template_Word_Word
* Zend_Grid_Template_Wordx_Wordx
* Zend_Grid_Translator
{zone-data}
{zone-data:use-cases}
{composition-setup}
{deck:id=use-cases1}
{card:label=UC 1 : Basic Usage}
UC1: Basic Usage
{code}
$select = $db->select()->from('Users');
$grid = new Zend_Grid::factory('Table',Zend_Config $config, $gridId);
$grid->setSource(new Zend_Grid_Source_Zend_Select($select));
$grid->deploy();
{code}
{card}
{card:label=UC 2 : Customize one field }
UC 2 : Customize one field
{code}
$select = $db->select()->from('Users',array('id','username','email','firstname','lastname','access'));
$grid = new Zend_Grid::factory('Table',Zend_Config $config, $gridId);
$grid->setSource(new Zend_Grid_Source_Zend_Select($select));
//Change title display for email column
$grid->updateColumn('email',array('title'=>"User's Email"));
//Id id column
$grid->updateColumn('id',array('hidden'=>1));
//Apply different css classes based on field value
$grid->setClassCellCondition('access', "'{{access}}' == 'admin'", "red", 'green');
$grid->deploy();
{code}
{card}
{card:label=UC 3 : CRUD Operations }
UC 3 : CRUD Operations
{code}
$grid = new Zend_Grid::factory('Table',Zend_Config $config);
$grid->setSource(new Zend_Grid_Source_Zend_Table(new Bugs()));
$form = new Zend_Grid_Form();
$form->setAdd(true)->setEdit(true)->setDelete(true);
$grid->setForm($form);
$grid->deploy();
{code}
{card}
{card:label=UC 4 : XML Source }
UC 4 : XML Source
{code}
$grid->setSource(new Zend_Grid_Source_Xml('http://zfdatagrid.com/feed/', 'channel,item'));
$grid->setNumberRecordsPerPage(10);
$grid->updateColumn('title', array('decorator' => '<a href="{{link}}">{{title}}</a>', 'style' => 'width:200px;'));
$grid->updateColumn('pubDate', array('class' => 'width_200'));
$grid->setGridColumns(array('title', 'comments', 'pubDate'));
{code}
{card}
{card:label=UC 5 : Mass Actions}
UC 5 : Mass Actions
{code}
$grid = new Zend_Grid::factory('Table',Zend_Config $config, $gridId);
$select = $this->_db->select()->from('Country');
$grid->query($select);
$grid->setMassAction(
array(
array(
'url' => $grid->getUrl(),
'caption' => 'Remove (Nothing will happen)',
'confirm' => 'Are you sure?'),
array(
'url' => $grid->getUrl() . '/nothing/happens',
'caption' => 'Some other action')
)
);
{code}
{card}
{card:label=UC 6 : Conditional Rendering}
UC 6 : Conditional Rendering
{code}
$grid = new Zend_Grid::factory('Table',Zend_Config $config, $gridId);
$select = $this->_db->select()->from('Country');
$grid->query($select);
$grid->setClassCellCondition('Population', "'{{Population}}' > 200000", "red", 'green');
$grid->setClassRowCondition("'{{Population}}' > 20000", "green", 'red');
{code}
{card}
{card:label=UC 7 : Extra Rows}
UC 7 : Extra Rows
{code}
$grid = new Zend_Grid::factory('Table',Zend_Config $config, $gridId);
$select = $this->_db->select()->from('Country', array('Name', 'Continent', 'Population', 'LocalName', 'GovernmentForm'));
$grid->setSource(new Zend_Grid_Source_Zend_Select($select));
$rows = new Zend_Grid_Extra_Rows();
$rows->addRow('beforeHeader', array('', array('colspan' => 1, 'class' => 'myclass', 'content' => 'my content'), array('colspan' => 2, 'class' => 'myotherclass', 'content' => 'some '), array('colspan' => 1, 'class' => 'myclass', 'content' => 'flowers:) ')));
rows->addRow('beforePagination', array(array('colspan' => 5, 'content' => "This is an extra row added before pagination")));
$grid->addExtraRows($rows);
{code}
{card}
{card:label=UC 8 : Others}
UC 8 : Others
[Check the source code of a controller|http://zfdatagrid.com/grid/site/code]
{card}
{deck}
{zone-data}
{zone-data:skeletons}
{composition-setup}
{deck:id=interface}
{card:label=UC 1 : Zend_Grid_Source_SourceInterface}