joacub / synergydatagrid
使用jqGrid JavaScript插件显示数据的模块
dev-master
2013-06-05 07:49 UTC
Requires
- php: >=5.3.3
- doctrine/doctrine-module: >=0.7
- doctrine/doctrine-orm-module: dev-master
- zendframework/zendframework: dev-master
Suggests
- gedmo/doctrine-extensions: dev-master
This package is not auto-updated.
Last update: 2024-09-23 14:29:45 UTC
README
简介
SynergyDataGrid 是一个Zend Framework 2模块,简化了在 ZF2 应用中使用 JqGrid。
它提供了一个基于 AJAX 的网格来编辑数据库表的基本 CRUD 功能。
要使用所有可用的插件和库功能,请阅读http://www.trirand.com/jqgridwiki/doku.php上的 jqGrid 文档。
依赖。
Zend Framework 2 (http://framework.zend.com/),
Doctrine 2.0 (http://www.doctrine-project.org/),
jQuery >= 1.4.2 (https://jqueryjs.cn),
jQuery UI 1.8.9 (https://jqueryui.jqueryjs.cn/),
jqGrid plugin >= 4.3.1 (http://www.trirand.com/blog/),
安装 - 手动
-
进入您的项目目录。
-
将此项目作为
synergydatagrid
模块克隆到您的./vendor/synergy/
目录git clone https://github.com/odiaseo/zf2-datagrid.git
-
将public目录中的所有文件复制到您的项目public文件夹
安装 - 使用 Composer
- 进入您的项目目录。
- 编辑您的
composer.json
文件,并在require
部分添加"synergy/synergydatagrid": "dev-master"
。 - 运行
php composer.phar install
(或php composer.phar update
)。 - 按照以下安装后步骤操作
安装后步骤
确保 DoctrineORM 配置正确
使用。
In your controller class:
<?php
use SynergyDataGrid\Grid\JqGridFactory ;
public function gridAction()
{
//replace {Entity_Name} with your entity name e.g. 'Application\Entity\User'
$serviceManager = $this->getServiceLocator() ;
$grid = $serviceManager->get('jqgrid')->setGridIdentity({Entity_Name});
/**
* this is the url where CRUD operations would be done via ajax
* :entity in the editurl could be any identifier or id. You would need to
* retrieve this and get the FQCN for use by the entity manager
* e.g. :entity = $this->getEntityKey({Entity_Name});
* @ see crudAction()
*/
$url = /ajax/:entity;
$grid->setUrl($url);
$grid->setCaption('My Caption'); //optional
return array('grid' => $grid);
}
public function crudAction()
{
$response = '';
/**
* Assumes that the entity can be retrieved from the ajax request
* e.g /ajax/:entity
* implement function to get the FQCN from :entity
*/
$entity = $this->params()->fromRoute('entity', null);
$className = $this->getClassname($entity);
if ( $className) {
$serviceManager = $this->getServiceLocator();
$grid = $serviceManager->get('jqgrid')->setGridIdentity( $className);
$response = $grid->prepareGridData();
}
return new JsonModel($response);
}
public function getEntityClassname($entityKey){
//@TODO implement as required
//return $entityClassname ;
}
public function getEntityKey($className){
//@TODO implement as required ;
//return $entity;
}
?>
In your view script:
<?php echo $this->displayGrid($this->grid); ?>
In head section of your layout:
<?php
$this->headLink()->appendStylesheet('/jqGrid/css/ui.jqgrid.css')
->appendStylesheet('/css/jquery.ui.datepicker.css')
->appendStylesheet('/plugins/ui.multiselect.css') ;
$this->headScript()->prependFile('https://ajax.googleapis.ac.cn/ajax/libs/jqueryui/1.8/jquery-ui.min.js', 'text/javascript')
->prependFile('https://ajax.googleapis.ac.cn/ajax/libs/jquery/1.8/jquery.min.js', 'text/javascript')
->appendFile('/jqGrid/js/i18n/grid.locale-en.js', 'text/javascript')
->appendFile('/plugins/ui.multiselect.js', 'text/javascript')
->appendFile('/jqGrid/js/jquery.jqGrid.min.js', 'text/javascript') ;
?>