Skip to content

Latest commit

 

History

History
128 lines (91 loc) · 3.06 KB

index.md

File metadata and controls

128 lines (91 loc) · 3.06 KB

APY DataGrid Bundle

APYDataGridBundle is a Symfony bundle for create grids for list your Entity (ORM), Document (ODM) and Vector (Array) sources. APYDataGridBundle was initiated by Stanislav Turza (Sorien) and inspired by Zfdatagrid and Magento Grid.

You can see CHANGELOG and UPGRADE 2.0.

Prerequisites

This version of the bundle requires Symfony 3.0+.

Translations

If you wish to use default texts provided in this bundle, you have to make sure you have translator enabled in your config.

# app/config/config.yml
framework:
    translator: ~

For more information about translations, check Symfony documentation.

Installation

Step 1 : Download APYDataGridBundle using composer

Require the bundle with composer :

$ composer require apy/datagrid-bundle

Composer will install the bundle to your project's vendor/apy/datagrid-bundle directory.

Step 2 : Enable the bundle

Enable the bundle in the kernel :

// app/AppKernel.php

public function registerBundles()
{
	$bundles = array(
		// ...
		new APY\DataGridBundle\APYDataGridBundle(),
		// ...
	);
}

Step 3 : Quick start with APYDataGridBundle

Create simple grid with an ORM source in your controller

<?php
namespace MyProject\MyBundle\Controller;

use APY\DataGridBundle\Grid\Source\Entity;

class DefaultController extends Controller
{
	public function myGridAction()
	{
		// Creates a simple grid based on your entity (ORM)
		$source = new Entity('MyProjectMyBundle:MyEntity');
		
		// Get a Grid instance
		$grid = $this->get('grid');
		
		// Attach the source to the grid
		$grid->setSource($source);
		
		// Return the response of the grid to the template
		return $grid->getGridResponse('MyProjectMyBundle:myGrid.html.twig');
	}
}

Create simple configuration of the grid in the entity

<?php
namespace MyProject\MyBundle\Entity

use Doctrine\ORM\Mapping as ORM;
use APY\DataGridBundle\Grid\Mapping as GRID;

/**
 * @GRID\Source(columns="id, my_datetime")
 */
class MyEntity
{
    /*
     * @ORM\Column(type="integer")
     */
    protected $id;

    /*
     * @ORM\Column(type="datetime")
     */
    protected $my_datetime;
}

Display the grid in a Twig template

<!-- MyProject\MyBundle\Resources\views\myGrid.html.twig -->
{{ grid(grid) }}

Don't forget to clean your cache !

Next Steps

Now you have completed the basic installation and configuration of the APYDataGridBundle, you are ready to learn about more advanced features and usages of the bundle.

The following documents are available :