joacub/synergydatagrid

使用jqGrid JavaScript插件显示数据的模块

安装: 5

依赖: 0

建议者: 0

安全: 0

星星: 0

关注者: 2

分支: 20

语言:JavaScript

类型:synergy-module

dev-master 2013-06-05 07:49 UTC

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/),

安装 - 手动

  1. 进入您的项目目录。

  2. 将此项目作为 synergydatagrid 模块克隆到您的 ./vendor/synergy/ 目录

    git clone https://github.com/odiaseo/zf2-datagrid.git

  3. 将public目录中的所有文件复制到您的项目public文件夹

安装 - 使用 Composer

  1. 进入您的项目目录。
  2. 编辑您的 composer.json 文件,并在 require 部分添加 "synergy/synergydatagrid": "dev-master"
  3. 运行 php composer.phar install(或 php composer.phar update)。
  4. 按照以下安装后步骤操作

安装后步骤

确保 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') ;
?>