Coder Social home page Coder Social logo

zfcdatagrid's Introduction

zfcdatagrid's People

Contributors

alessandropietrobelli avatar bitdeli-chef avatar blacktemplar avatar cbastienbaron avatar e-belair avatar fragote avatar igorhaf avatar imonteiro avatar jonathangreco avatar keanor avatar kokspflanze avatar locutusofpenguin avatar lorenzoferrarajr avatar nsenkevich avatar prolic avatar rezix avatar thadafinser avatar vex avatar vixriihi avatar webdevilopers avatar weckx avatar zeineddin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zfcdatagrid's Issues

use of GROUP_CONCAT as a column and search

I am trying to use some custom doctrine 2 mysql function from https://github.com/beberlei/DoctrineExtensions like (GROUP_CONCAT), I am selecting it in a column, but it seems that the query is selecting the following:

a.group_concat(w.word) a_group_concat(w.word)

I am calling this by

$col = new Column\Standard('group_concat(w.word)', 'a');

and I am getting the following error:

[Syntax Error] line 0, col 33: Error: Expected Doctrine\ORM\Query\Lexer::T_FROM, got '('

am I doing something wrong? also how can I make this column searchable? will it produce any error?

Combining features LemoGrid with ZfcDatagrid

Hallo,

I'm working on module which provides building of data grids similar to Zend Form for many platforms (jqGrid, DataTables, ...).

I found many great things in your module, so I can ask to you if we can merge both grids together.

Some thinks to merge from my module:

  • Creating of grid, column, platform and adapters via Factory
  • Creating of grid similar to Zend Form
  • Route and Concat column

Source code: https://github.com/MatyCZ/LemoGrid

Best Regards

Matej Szendi

Create columns with config

Provide the possibility to create columns out of configuration.

Example:

$col1 = array('label' => 'MyLabel', 'width' => 20);
$col2 = array('label' => 'secondCol', 'width' => 30, ....)
$columns = array($col1, $col2);
$grid->setColumns($columns)

//OR
$grid->addColumn($col1);
$grid->addColumn($col2);

Custom colunm display

What do you think if there is a new column rendered type (I don't know what to call it) and in this type the user supply the column with a call back function to executed on the column value, or better to be executed on the whole row to get the value to be displayed in the table cell, in this way the user will have a full control on how to display a column content.
I think this feature will be extremely useful for the very custom display ways, what do you think?

Not all identifier properties can be found in the ResultSetMapping: id

I just got the latest updates of the ZfcDatagrid, and I am using it with Doctrin2, just selecting from one entity, and I got this error after the update:

Not all identifier properties can be found in the ResultSetMapping: id

In my action my code is simple as the following:

$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('p')->from('Permissions', 'p');

$dataGrid = $this->getServiceLocator()->get('zfcDatagrid');
$dataGrid->setDefaultItemsPerPage(50);
$dataGrid->setDataSource($qb);

$permId = new Column\Standard('id', 'p');
$permId->setIdentity();
$dataGrid->addColumn($permId);

$permissionCode = new Column\Standard('permissionCode', 'p');
$permissionCode->setLabel('Permission Code');
$permissionCode->setSortDefault(1, 'ASC');
$permissionCode->addStyle(new Style\Bold());
$dataGrid->addColumn($permissionCode);

$permissionDesc = new Column\Standard('permissionDesc', 'p');
$permissionDesc->setLabel('Permission Desc');
$dataGrid->addColumn($permissionDesc);

$dataGrid->execute();

return $dataGrid->getResponse();

I noticed that there has been some changes in Doctrine files, do I have to change anything in my code?

zfcDatagrid Implementation To My Project

I Download ZfcDatagrid to my Project and i implement it but its not working it says Controller not found..can u help me..
Class 'ZfcDatagrid\Examples\Controller\PersonDoctrine2Controller' not found

Functions from jqGrid doesn't work

If you set Renderer to jqGrid you can't use any of functions (as sorting, filtering etc) from jqGrid. I assume that problem is with the url path. It doesn't work in Examples as well. But if you sort results and then you export them to excel they are sorted. So maybe problem is with reloading table.

Doctrine Integration & ZfcDatagrid

Hi thanks for your module, I need to connect a CmsPagesRepository class to the ZfcDatagrid but I have found some difficulties.

This is the Repository:

<?php
namespace Cms\Repository;

use Doctrine\ORM\EntityRepository;

class CmsPagesRepository extends EntityRepository
{
    public function getData()
    {
        $pages = $this->getEntityManager()
                ->createQueryBuilder()
                ->select('cms')
                ->from('\Cms\Entity\CmsPages', 'cms');

        return $pages;
    }
}

This is the Service:

<?php

namespace Cms\Service;

use \ZfcDatagrid\Column;
use \Cms\Repository\CmsPagesRepository;

class Pages {

    protected $datagrid;
    protected $repository;

    public function __construct(\ZfcDatagrid\Datagrid $datagrid, CmsPagesRepository $theRepository)
    {
        $this->repository = $theRepository;
        $this->datagrid = $datagrid;
    }

    /**
     * Create the Datagrid for the CMS pages
     * @return \ZfcDatagrid\Ambigous
     */
    public function getGrid(){

        /* @var $grid \ZfcDatagrid\Datagrid */
        $grid = $this->datagrid;
        $grid->setTitle('Cms List');

        $grid->setDefaultItemsPerPage(5);

        $grid->setDataSource($this->repository->getData());

        $col = new Column\Select('title');
        $col->setLabel('Title');
        $grid->addColumn($col);
        $grid->render();

        return $grid->getResponse();
    } 
}

This is the error:

[Semantical Error] line 0, col 7 near 'title title FROM': Error: 'title' does not point to a Class. 

SELECT title title FROM \Cms\Entity\CmsPages cms

Why I get this error? Is this a bug?

thanks

Mass Actions

It's possible provide the possibility to perfom some action on multiple rows, by adding an extra column with a checkbox and passing the primary key throw POST.

Example:

$action1 = array('url' => '/action1', 'caption' => 'Some action');
$action2 = array('url' => '/action2', 'caption' => 'Another action');
$actions = array($action1, $action2);
$grid->setMassActions($actions )

//OR
$grid->addMassAction($action1);
$grid->addMassAction($action2);

ZendSelect->execute() is not generating correct SQL

Hi, I'm having some trouble using the ZfcDatagrid with Zend\Db\Sql\Select. I traced what I think the problem is back to the execute method.

/**
 * Step 1) Apply needed columns
 */
 $selectColumns = array();
 foreach ($this->getColumns() as $column) {

    if ($column instanceof Column\Select) {
        $selectColumns[$column->getUniqueId()] = $column->getSelectPart2();
    }
 }
 // @note Table "Prefix" should be set automatically, so $column->getSelectPart1() is not needed...
 $select->columns($selectColumns);

$column->getSelectPart2() is returning an empty string. My code for creating the grid looks like:

        $dbAdapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
        $select = new Select();
        $select->from(array('o' => 'Orders'));

        $grid = $this->getServiceLocator()->get('ZfcDatagrid\Datagrid');
        $grid->setTitle('Orders');

        $grid->setDataSource($select, $dbAdapter);

        $col = new Column\Select('order_id');
        $col->setLabel('ID');
        $grid->addColumn($col);

        $col = new Column\Select('order_number');
        $col->setLabel('Number');
        $grid->addColumn($col);

        $grid->render();

        return $grid->getResponse();

If I add the following debug code to line 93 of ZendSelect

var_dump($selectColumns, $select->getSqlString());exit;

It returns

array (size=2)
  'order_id' => null
  'order_number' => null
string 'SELECT "o"."" AS "order_id", "o"."" AS "order_number" FROM "Orders" AS "o"' (length=74)

By changing the code to use $column->getSelectPart1(), it seemed to work fine - but I'm not sure if that's the correct approach to fix this. I'm using the Pdo driver for my db adapter. Let me know if you need any more information to help debug this.

Thanks!

Translator error

I'm receiving this error:

Catchable fatal error: Argument 1 passed to ZfcDatagrid\Datagrid::setTranslator() must be an instance of Zend\I18n\Translator\Translator, instance of Zend\Mvc\I18n\Translator given, called in \vendor\thadafinser\zfc-datagrid\src\ZfcDatagrid\Service\DatagridFactory.php on line 27 and defined in \vendor\thadafinser\zfc-datagrid\src\ZfcDatagrid\Datagrid.php on line 402
Call Stack
#   Time    Memory  Function    Location
1   0.0004  258456  {main}( )   ..\index.php:0
2   0.2230  11774816    Zend\Mvc\Application->run( )    ..\index.php:29
3   0.2255  11902624    Zend\EventManager\EventManager->trigger( )  ..\Application.php:310
4   0.2255  11902624    Zend\EventManager\EventManager->triggerListeners( ) ..\EventManager.php:207
5   0.2256  11904688    call_user_func ( )  ..\EventManager.php:468
6   0.2256  11904720    Zend\Mvc\DispatchListener->onDispatch( )    ..\EventManager.php:468
7   0.2305  12038944    Zend\Mvc\Controller\AbstractController->dispatch( ) ..\DispatchListener.php:114
8   0.2306  12039568    Zend\EventManager\EventManager->trigger( )  ..\AbstractController.php:117
9   0.2306  12039568    Zend\EventManager\EventManager->triggerListeners( ) ..\EventManager.php:207
10  0.2311  12052816    call_user_func ( )  ..\EventManager.php:468
11  0.2311  12052848    Zend\Mvc\Controller\AbstractActionController->onDispatch( ) ..\EventManager.php:468
12  0.2311  12053072    App\Controller\ConsumersController->listAction( )   ..\AbstractActionController.php:83
13  0.2311  12053280    Zend\ServiceManager\ServiceManager->get( )  ..\ConsumersController.php:19
14  0.2312  12054392    Zend\ServiceManager\ServiceManager->create( )   ..\ServiceManager.php:504
15  0.2312  12054392    Zend\ServiceManager\ServiceManager->doCreate( ) ..\ServiceManager.php:564
16  0.2312  12054440    Zend\ServiceManager\ServiceManager->createFromFactory( )    ..\ServiceManager.php:604
17  0.2320  12064024    Zend\ServiceManager\ServiceManager->createServiceViaCallback( ) ..\ServiceManager.php:1023
18  0.2320  12064376    call_user_func ( )  ..\ServiceManager.php:893
19  0.2320  12064416    ZfcDatagrid\Service\DatagridFactory->createService( )   ..\ServiceManager.php:893
20  0.2394  12440104    ZfcDatagrid\Datagrid->setTranslator( )  ..\DatagridFactory.php:27

Should use Zend\Mvc\I18n\Translator instead of Zend\I18n\Translator\Translator?
(http://framework.zend.com/blog/zend-framework-2-2-0-stable-released.html)

Entity properties that are relations not supported?

Hi all,

Thanks for this great module, I like the way you guys have set this up. I only have one question: Is there support for (Doctrine) entity properties that are a relationship... I tried this in a project I'm doing and I get the following errors.

[Semantical Error] line 0, col 20 near 'productgroep': Error: Invalid PathExpression. Must be a StateFieldPathExpression.

The following query gives this error, where p.productgroep is a relation.

SELECT p.id p_id, p.productgroep p_productgroep, p.titel p_titel FROM Product\Entity\Product p

The column in my controller is defined like this:

$col = new Column\Standard('productgroep', 'p');
$col->setLabel('Productgroep');
$col->setWidth(25);
$dataGrid->addColumn($col);

The relation described in p.productgroep looks like the following and is functioning normal in my other code so that does not seem to be the problem.

/**
 * @ORM\ManyToOne(targetEntity="Product\Entity\Productgroep", fetch="EAGER")
 * @ORM\JoinColumn(name="productgroep_id", referencedColumnName="product_groep_id")
 */

I'm using ZF2 v2.1.5 and Doctrine v2.3.0.

I hope I've given enough information, if not please ask!

Cheers

Store parameters in session

Is it possible to store sortBy, sortDirection & currentPage in session to retrieve them when back to the page?

Conditional decoration (row/column)

It's possible provide the possibility to perfom conditional decoration by row/column.

Example:

// row
// apply "green" css class to row when columnB is greater than 0
$grid->setClassRowCondition('columnB > 0', 'green');

// column
// apply "green" css class to cell columnA when columnB is greater than 0
$grid->addClassCellCondition('columnA', 'columnB > 0', 'green');
// OR
$col->addClassCondition('columnB > 0', 'green');

Parameter handling

Move the parameter handling (page, sort, filtering) to the different renderer.

Why: Every renderer can have different parameter names

Create config options for the parameter names

Search field extended

I'm using bootstrapTable. It's possible define search field types?

Examples:

  • Combobox: pre-defined values or based on column values
  • Date/Time: calendar popup (jquery)
  • From/To: two fields (numbers, dates, etc.)... like BETWEEN

Installation not possible without doctrine

After installing ZfcDatagrid in a new ZendSkeletonApplication, I get the following error message when I go to http://localhost/ZendSkeletonApplication/public

Fatal error: Class 'DoctrineORMModule\Service\DBALConnectionFactory' not found in C:\htdocs\ZendSkeletonApplication\vendor\thadafinser\zfc-datagrid\src\ZfcDatagrid\Module.php on line 88

The ZfcDatagrid documentation does not mention that I have to install DoctrineORMModule to see some grid examples. Can ZfcDatagrid be used without doctrine?

Problem with column filter when displaying data from DB using Zend\Db

I set up a grid with a userID and a username column. Data is read from the database. Displaying, paginating, and sorting the data works, but when I want to filter usernames, I get the an exception:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'u_username' in 'where clause'

The column name is username, not u_username. Somehow, the table alias is prepended to the column name. Is this a bug or am I doing something wrong? Here's my code:

public function testUserMonitorAction()
{
    /* @var $dataGrid \ZfcDatagrid\Datagrid */
    $dbAdapter = $this->diFactory()->createZf2DbAdapter();

    $select = new \Zend\Db\Sql\Select;
    $select->from(array('u' => 'users'));
    $dataGrid = $this->getServiceLocator()->get('zfcDatagrid');
    $dataGrid->setTitle('Minimal grid');
    $dataGrid->setDefaultItemsPerPage(3);
    $dataGrid->setDataSource($select, $dbAdapter);

    $col = new Column\Select('userID', 'u');
    $col->setLabel('ID');
    $col->setIdentity();
    $col->setHidden(false);
    $dataGrid->addColumn($col);

    $col = new Column\Select('username', 'u');
    $col->setLabel('username');
    $dataGrid->addColumn($col);

    $dataGrid->render();

    return $dataGrid->getResponse();
}

Folding rows with ZfcDatagrid

In our application, we have some twitter-bootstrap based datagrid with folding rows. I'm thinking about refactoring using ZfcDatagrid, but I'd like to know first if folding rows are supported or can be implemented easily.

image

Also, cell contents contain tooltips, links, and action buttons with tooltips. Some cells contain concatenated values. The value for the progress column e.g. is concatenated as follows:

sprintf('%s / %s (%d%%)', $currentPage, $pageCount, $currentPage / $pageCount * 100)

Can I replicate this type of grid with ZfcDatagrid or is this too custom?

setIdentity and getRowIdPlaceholder

Hello,

I've a grid with a column with ->setIdentity().

I've make a action on a column with :

->setAttribute('href', '/fiche/' . $action->getRowIdPlaceholder());

It's work fine.

But when i'm click on a column for a sort, i've the error :

Notice: Undefined index: idConcated in /home/maxime.malus-zf.redmine.itika.net/application/vendor/thadafinser/zfc-datagrid/src/ZfcDatagrid/Column/Action/AbstractAction.php on line 69

I've forgotten anything ? :(

PlaceHolder on Action Label

Hi,

Should be nice to make a label containing a placeHolder like setLink can do
Eg

$action->setLabel($action->getColumnValuePlaceholder($col).' try remaining!');

Execute with hhvm

When I run the compiler hhvm,

hhvm index.php person datagrid

I get the warning
HipHop Warning:Parameter 1 toarray_multisort()expectedto beareference, valuegiven in HipHop Warning: Parameter 1 to array_multisort() expected to be a reference, value given in /var/www/zftest/vendor/thadafinser/zfc-datagrid/src/ZfcDatagrid/DataSource/PhpArray.php on line 148
HipHop Warning: Parameter 2 to array_multisort() expected to be a reference, value given in /var/www/zftest/vendor/thadafinser/zfc-datagrid/src/ZfcDatagrid/DataSource/PhpArray.php on line 148

This is because the code of PhpArray.php need to pass two values​ ​by reference
140:$arguments[] = &$DataCol;
141:foreach ( $sortParameters as $parameter){
142: $arguments[]= &$parameter;

Add more elements to the rendered grid view

I am using the ZfcDatagrid, and I want to add more elements to the rendered view, like some extra-filtering form, or even I want to add some html elements or links before or after the grid, how can I do that?

Remove usage of `Module#getServiceConfig`

A lot of services that are invokables are currently defined via closure factories.

Remaining closures should be converted to factories and the Module#getServiceConfig should completely be removed

Strange issue when I try to execute it by shell

$ php index.php datagrid category

Fatal error: Call to a member function plugin() on a non-object in .../myproject/vendor/zendframework/zendframework/library/Zend/View/Helper/HeadMeta.php on line 320

$ php index.php datagrid person

Fatal error: Class 'NumberFormatter' not found in .../myproject/vendor/thadafinser/zfc-datagrid/src/ZfcDatagrid/Column/Type/Number.php on line 38

Regards

Actions depending on columns like Edit with parameters

When using this module, I needed to pass a link to an Action Button for the edit or show or whatever to do with the record, this link must have some parameters from the row data itself, like the identity and/or other columns values to be passed.
I think this would be a big requirement when using a Datagrid... and I think it is missing, right?

Syntax error in module.config.php

On a default LAMP stack i get:

PHP Parse error: syntax error, unexpected '[' in vendor/thadafinser/zfc-datagrid/config/module.config.php on line 102

Fail to load default : FATAL ERROR installation

Hello,

I test it but I install like indicate it to site and I have a Fatal Error :

Fatal error: Class 'NumberFormatter' not found in /Applications/AMPPS/www/ZendSkeletonApplication/vendor/thadafinser/zfc-datagrid/src/ZfcDatagrid/Column/Type/Number.php on line 38

Thanks

Export issue

I'm using this approach:

Files:

myModule/Controller/IndexController.php
myModule/Grid/gridA.php

In my controller action:

$dataGrid = $this->getServiceLocator()->get('zfcDatagrid');
$grid = new GridProjectList();

$view = new ViewModel();
$view->addChild($grid->grid($dataGrid, $data), 'grid');

return $view;

In my gridA.php class:

public function grid($dataGrid, $data)
{

    $dataGrid->setDataSource($data);

    $col = new Column\Select('id', 'p');
    $col->setIdentity();
    $dataGrid->addColumn($col);

    $col = new Column\Select('identifier', 'p');
    $col->setLabel('ID');
    $dataGrid->addColumn($col);

    $col = new Column\Select('name', 'p');
    $col->setLabel('Name');
    $col->setWidth(10);
    $col->addStyle(new Style\Bold());

    $dataGrid->render();

    return $dataGrid->getResponse();
}

When exporting to Excel I receive this error:

Catchable fatal error: Argument 1 passed to Zend\View\Model\ViewModel::addChild() must implement interface Zend\View\Model\ModelInterface, instance of Zend\Http\Response\Stream given, called in \module\efaProject\src\EfaProject\Controller\ProjectController.php on line 35 and defined in \vendor\zendframework\zendframework\library\Zend\View\Model\ViewModel.php on line 337

I'm doing something wrong? Or you suggest other approach?

Thanks.

Doctrine example not working

The error:
Class 'ZfcDatagrid\Datasource\Doctrine2Paginator' not found in vendor/thadafinser/zfc-datagrid/src/ZfcDatagrid/DataSource/Doctrine2.php on line 101

Possible fix:

src/ZfcDatagrid/DataSource/Doctrine2.php on line 101:
edit: $this->setPaginatorAdapter(new PaginatorAdapter($queryBuilder));
to: $this->setPaginatorAdapter(new Doctrine2Paginator($queryBuilder));

src/ZfcDatagrid/DataSource/Doctrine2.php on line 5 :
Remove : use ZfcDatagrid\Datasource\Doctrine2Paginator as PaginatorAdapter;

Zend Studio 10.1 example zfcdatagrid

hello

i used zfcdatagrid from github. want to know the corrrect way of using it. my way createdlocal project in zf2 and it has application module default. i pasted the zfcdatagrid module under folder 'module' did relevant changes like in config\application.config.php added 'zfcdatagrid'. global.php, local.php added my won db, table but dint work

Column callback

Its possible set a callback function to some column, in order to return some value based on conditions (external params or other columns values, passed as variables to the callback function).

Example:

$col->setCallbackFunction(
   create_function('$a, $b', 'if($a>$b) { return "No"; } else { return "Yes"; }'),
   array(
       $externalValue,
       'columnBvalue'
    )
):

Thanks.

Doctrine2 Pagination wrong

The Doctrine2 pagination is really a problem.

The Doctrine2 solution needs 3 queries and the current included is not correctly for all querys...

A mix of Doctrine2 pagination and the old ZF1 Paginator will be come into play here...

Identify cells in a row

It would be very helpful to be able to identify cells in row and a column in general, for example I want to attach an on-click event on all column cells or a specific cell, and I wont depend on the order, so for example a td attribute or something like this added to the will identify cells.

Also is there a way to display a specific value when it is empty or null? for example a cell is empty and so I want to add an "Add" button, is this possible? or even better to have a specific template to be displayed in case of null or empty.

Audit Log Feature

HI Martin,
I had already seen this module from zf mail list , and I think If I could add Audit Log Feature .
I had created a ZF2 Module That provide auditing for doctrine orm , it would be great If I created some view helpers that would view the audit log for each row in your grid , i think it would be very helpful and would make very nice combination

ZF2EntityAudit : https://packagist.org/packages/tawfekov/zf2entityaudit
ZF2EntityAudit Demo : https://github.com/tawfekov/ZF2EntityAudit-demo/

what do you think ?
tawfek

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.