matycz / lemo-grid
jqGrid integration to Laminas
Installs: 8 331
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 5
Forks: 0
Open Issues: 0
Requires
- php: ^8.0
- ext-intl: *
- ext-json: *
- laminas/laminas-eventmanager: ^3.0
- laminas/laminas-i18n: ^2.0
- laminas/laminas-json: ^3.0
- laminas/laminas-mvc: ^3.0
- laminas/laminas-paginator: ^2.10
- laminas/laminas-servicemanager: ^3.0
- laminas/laminas-stdlib: ^3.0
Suggests
- doctrine/orm: Needed to support Adapter\Doctrine\QueryBuilderAdapter
- laminas/laminas-db: Needed to support Adapter\Laminas\CombineAdapter or Adapter\Laminas\SelectAdapter
- laminas/laminas-paginator-adapter-laminasdb: Needed to support Adapter\Laminas\CombineAdapter or Adapter\Laminas\SelectAdapter
- laminas/laminas-session: Needed to support Storage\Php\SessionStorage
- dev-master
- 5.2.0
- 5.1.1
- 5.1.0
- 5.0.2
- 5.0.1
- 5.0.0
- 4.0.0
- 3.0.2
- 3.0.1
- 3.0.0
- 2.0.2
- 2.0.1
- 2.0.0
- 1.15.7
- 1.15.6
- 1.15.5
- 1.15.4
- 1.15.3
- 1.15.2
- 1.15.1
- 1.15.0
- 1.14.3
- 1.14.2
- 1.14.1
- 1.14.0
- 1.13.1
- 1.13.0
- 1.12.5
- 1.12.4
- 1.12.3
- 1.12.2
- 1.12.1
- 1.12.0
- 1.11.1
- 1.11.0
- 1.10.4
- 1.10.3
- 1.10.2
- 1.10.1
- 1.9.1
- 1.9.0
- 1.8.10
- 1.8.9
- 1.8.8
- 1.8.7
- 1.8.6
- 1.8.5
- 1.8.4
- 1.8.3
- 1.8.2
- 1.8.1
- 1.8.0
- 1.7.3
- 1.7.2
- 1.7.1
- 1.7.0
- 1.6.8
- 1.6.7
- 1.6.6
- 1.6.5
- 1.6.4
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.5
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.1
- 1.4.0
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.1
- 1.2.0
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-legacy-1.x
This package is auto-updated.
Last update: 2024-06-12 10:45:41 UTC
README
The LemoGrid module provides building of data grids similar to Laminas Form quickly and easily for many platforms.
Supported plaforms
- jqGrid - jQuery Grid Plugin (trirand.com)
Supported data adapters
- Doctrine\QueryBuilder (doctrine-project.org)
- Laminas\Db\Sql (github.com/laminas/laminas-db)
Features / Goals
- Add column Concat [In progress]
- Add column Route [In progress]
- Write documentation
- Write tests
Installation
Installation of this module uses composer. For composer documentation, please refer to getcomposer.org.
Installation steps
-
cd my/project/directory
-
Create a
composer.json
file with following contents:{ "require": { "matycz/lemo-grid": "0.*" } }
-
Run
php composer.phar install
-
Open
my/project/directory/config/application.config.php
and add following keys to yourmodules
'LemoGrid',
Installation without composer is not officially supported, and requires you to install and autoload
the dependencies specified in the composer.json
.
Examples
<?php namespace Foo; use LemoGrid\ModuleManager\Feature\GridProviderInterface; use Laminas\ModuleManager\Feature\ControllerProviderInterface; use Laminas\ModuleManager\Feature\ServiceProviderInterface; class Module implements ControllerProviderInterface, GridProviderInterface, ServiceProviderInterface { ... /** * @inheritdoc */ public function getControllerConfig() { return array( 'factories' => array( 'Foo\Controller\Bar' => function($controllerManager) { $controller = new Controller\BarController(); $controller->setGridBar($controllerManager->getServiceLocator()->get('Foo\Grid\Bar')); $controller->setServiceBar($controllerManager->getServiceLocator()->get('Foo\Service\Bar')); return $controller; }, ) ); } /** * @inheritdoc */ public function getGridConfig() { return array( 'factories' => array( 'Foo\Grid\Bar' => function () { $grid = new Grid\Bar(); return $grid; }, ) ); } /** * @inheritdoc */ public function getServiceConfig() { return array( 'factories' => array( 'Foo\Service\Bar' => function ($serviceManager) { $service = new Service\Bar($serviceManager); $service->setEntityManager($serviceManager->get('Doctrine\ORM\EntityManager')); return $service; }, ), ); } ... }
<?php namespace Foo\Controller; use Foo\Grid\Bar as GridBar; use Foo\Service\Bar as ServiceBar; use Laminas\Mvc\Controller\AbstractActionController; use Laminas\View\Model\ViewModel; class BarController extends AbstractActionController { /** * @var GridBar */ protected $gridBar; /** * @var ServiceBar */ protected $serviceBar; /** * Page with grid example * * @return ViewModel */ public function indexAction() { $adapter = new \LemoGrid\Adapter\Doctrine\QueryBuilder(); $adapter->setQueryBuilder($this->getServiceBar()->getQueryBuilderInstanceForGrid()); $platform = new \LemoGrid\Platform\JqGrid(); $grid = $this->getGridBar(); $grid->setAdapter($adapter); $grid->setPlatform($platform); $grid->setParams($this->params()->fromQuery()); return new ViewModel(array( 'grid' => $grid )); } ... /** * @param GridBar $gridBar * @return BarController */ public function setGridBar(GridBar $gridBar) { $this->gridBar = $gridBar; return $this; } /** * @return GridBar */ public function getGridBar() { return $this->gridBar; } /** * @param ServiceBar $serviceBar * @return BarController */ public function setServiceBar(ServiceBar $serviceBar) { $this->serviceBar = $serviceBar; return $this; } /** * @return ServiceBar */ public function getServiceBar() { return $this->serviceBar; } }
<?php namespace Foo\Service; use Doctrine\ORM\EntityManager; use Doctrine\ORM\QueryBuilder; class Bar { /** * @var EntityManager */ protected $entityManager; /** * Return instance of QueryBuilder for grid * * @return QueryBuilder */ public function queryGrid() { $qb = $this->getEntityManager()->createQueryBuilder() ->select(array('rootAlias')) ->from('Foo\Entity\Bar', 'rootAlias'); return $qb; } /** * Set entity manager * * @param EntityManager $entityManager * @return Bar; */ public function setEntityManager(EntityManager $entityManager) { $this->entityManager = $entityManager; return $this; } /** * Get entity manager * * @return EntityManager */ public function getEntityManager() { return $this->entityManager; } }
<?php namespace Foo\Grid; use LemoGrid\Grid; class Bar extends Grid { public function init() { $this->setName('GridBar'); // NAME $this->add(array( 'name' => 'name', 'type' => 'text', 'identifier' => 'rootAlias.name', 'attributes' => array( 'label' => 'Name', 'width' => '70', ) )); // VERSION $this->add(array( 'name' => 'version', 'type' => 'text', 'identifier' => 'rootAlias.version', 'attributes' => array( 'label' => 'Version', 'width' => '20', ) )); // EDIT $this->add(array( 'name' => 'edit', 'type' => 'route', 'options' => array( 'text' => '<i class="icon-pencil icon-white"></i>', 'template' => '<a href="%s" class="btn btn-mini btn-primary">%s</a>', 'route' => 'foo/bar', 'params' => array( 'action' => 'edit', 'id' => '%rootAlias.id%' ), 'reuseMatchedParams' => true, ), 'attributes' => array( 'width' => '5', 'align' => 'center', 'isSortable' => false, 'isSearchable' => false, ) )); // DELETE $this->add(array( 'name' => 'delete', 'type' => 'route', 'options' => array( 'text' => '<i class="icon-trash icon-white"></i>', 'template' => '<a href="%s" class="btn btn-mini btn-primary dialog-delete">%s</a>', 'route' => 'foo/bar', 'params' => array( 'action' => 'delete', 'id' => '%rootAlias.id%' ), 'reuseMatchedParams' => true, ), 'attributes' => array( 'width' => '5', 'align' => 'center', 'isSortable' => false, 'isSearchable' => false, ) )); } }
<?php $this->headLink()->appendStylesheet('/css/jqGrid/jqGrid.css'); $this->headScript()->appendFile('/js/jqGrid/jqGrid.js'); ?> <div class="row-fluid"> <div class="span12 box"> <?= $this->jqgrid($this->grid) ?> </div> </div>