Skip to content

Commit

Permalink
[ISSUE-2] Fix doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Teixeira committed Mar 11, 2013
1 parent 991a66d commit 4d04058
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 122 deletions.
216 changes: 108 additions & 108 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,49 +18,49 @@ Installation

1. **Add as a dependency in your composer file**

```json
"require": {
```json
"require": {
"pedro-teixeira/grid-bundle":"dev-master"
}
```

2. **Add to your Kernel**

```php
```php
// application/ApplicationKernel.php
public function registerBundles()
{
$bundles = array(
new PedroTeixeira\Bundle\GridBundle\PedroTeixeiraGridBundle()
new PedroTeixeira\Bundle\GridBundle\PedroTeixeiraGridBundle()
);
}
}
```

3. **Add to your assetics configuration**

```yml
```yml
// application/config/config.yml
assetic:
bundles: [ PedroTeixeiraGridBundle ]
bundles: [ PedroTeixeiraGridBundle ]
```

4. **Add assets to your layout**

```twig
{% stylesheets
'@PedroTeixeiraGridBundle/Resources/public/css/grid.css'
%}
<link href="{{ asset_url }}" type="text/css" rel="stylesheet" media="screen" />
{% endstylesheets %}
```
```twig
{% stylesheets
'@PedroTeixeiraGridBundle/Resources/public/css/grid.css'
%}
<link href="{{ asset_url }}" type="text/css" rel="stylesheet" media="screen" />
{% endstylesheets %}
```

```twig
{% javascripts
```twig
{% javascripts
'@PedroTeixeiraGridBundle/Resources/public/js/grid.js'
%}
%}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
```
```


Create your grid
Expand All @@ -73,98 +73,98 @@ Create your grid
```php
<?php

namespace PedroTeixeira\Bundle\TestBundle\Grid;

use PedroTeixeira\Bundle\GridBundle\Grid\GridAbstract;

/**
* Test Grid
*/
class TestGrid extends GridAbstract
{
/**
* {@inheritdoc}
*/
public function setupGrid()
{
$this->addColumn('ID')
->setField('id')
->setIndex('r.id')
->getFilter()
->getOperator()
->setComparisonType('equal');

$this->addColumn('Created At')
->setField('createdAt')
->setIndex('r.createdAt')
->setFilterType('date_range')
->setRenderType('date');

$this->addColumn('Name')
->setField('name')
->setIndex('r.name');

$this->addColumn('Options')
->setField('option')
->setIndex('r.options')
->setFilterType('select')
->getFilter()
->setOptions(array(
'key' => 'value'
));

$this->addColumn('Action')
->setTwig('PedroTeixeiraTestBundle:Test:gridAction.html.twig')
->setFilterType(false);
}
}
namespace PedroTeixeira\Bundle\TestBundle\Grid;

use PedroTeixeira\Bundle\GridBundle\Grid\GridAbstract;

/**
* Test Grid
*/
class TestGrid extends GridAbstract
{
/**
* {@inheritdoc}
*/
public function setupGrid()
{
$this->addColumn('ID')
->setField('id')
->setIndex('r.id')
->getFilter()
->getOperator()
->setComparisonType('equal');

$this->addColumn('Created At')
->setField('createdAt')
->setIndex('r.createdAt')
->setFilterType('date_range')
->setRenderType('date');

$this->addColumn('Name')
->setField('name')
->setIndex('r.name');

$this->addColumn('Options')
->setField('option')
->setIndex('r.options')
->setFilterType('select')
->getFilter()
->setOptions(array(
'key' => 'value'
));

$this->addColumn('Action')
->setTwig('PedroTeixeiraTestBundle:Test:gridAction.html.twig')
->setFilterType(false);
}
}
```

2. **Use the grid factory in your controller**

```php
<?php

namespace PedroTeixeira\Bundle\TestBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

use JMS\SecurityExtraBundle\Annotation\Secure;

/**
* Default controller
*/
class DefaultController extends Controller
{
/**
* @Route("/", name="test")
* @Template()
*
* @return array
*/
public function indexAction()
{
/** @var \Doctrine\ORM\EntityRepository $repository */
$repository = $this->getDoctrine()->getRepository('PedroTeixeiraTestBundle:TestEntity');
$queryBuilder = $repository->createQueryBuilder('r');

/** @var \PedroTeixeira\Bundle\TestBundle\Grid\TestGrid $grid */
$grid = $this->get('pedroteixeira.grid')->createGrid('\PedroTeixeira\Bundle\TestBundle\Grid\TestGrid');
$grid->setQueryBuilder($queryBuilder);

if ($grid->isAjax()) {
return $grid->render();
}

return array(
'grid' => $grid->render()
);
}
}
```
```php
<?php

namespace PedroTeixeira\Bundle\TestBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

use JMS\SecurityExtraBundle\Annotation\Secure;

/**
* Default controller
*/
class DefaultController extends Controller
{
/**
* @Route("/", name="test")
* @Template()
*
* @return array
*/
public function indexAction()
{
/** @var \Doctrine\ORM\EntityRepository $repository */
$repository = $this->getDoctrine()->getRepository('PedroTeixeiraTestBundle:TestEntity');
$queryBuilder = $repository->createQueryBuilder('r');

/** @var \PedroTeixeira\Bundle\TestBundle\Grid\TestGrid $grid */
$grid = $this->get('pedroteixeira.grid')->createGrid('\PedroTeixeira\Bundle\TestBundle\Grid\TestGrid');
$grid->setQueryBuilder($queryBuilder);

if ($grid->isAjax()) {
return $grid->render();
}

return array(
'grid' => $grid->render()
);
}
}
```

3. **Render in your template**

Expand All @@ -177,5 +177,5 @@ Understanding

* [Grid](https://github.com/pedro-teixeira/grid-bundle/tree/master/Resources/doc/grid.md)
* [Column](https://github.com/pedro-teixeira/grid-bundle/tree/master/Resources/doc/column.md)
* [Render](https://github.com/pedro-teixeira/grid-bundle/tree/master/Resources/doc/column/render.md)
* [Filter](https://github.com/pedro-teixeira/grid-bundle/tree/master/Resources/doc/column/filter.md)
* [Render](https://github.com/pedro-teixeira/grid-bundle/tree/master/Resources/doc/column/render.md)
* [Filter](https://github.com/pedro-teixeira/grid-bundle/tree/master/Resources/doc/column/filter.md)
18 changes: 9 additions & 9 deletions Resources/doc/column.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Usage:
```php
public function setupGrid()
{
$this->addColumn('Column Name');
$this->addColumn('Column Name');
}
```

Expand All @@ -27,8 +27,8 @@ Usage:
```php
public function setupGrid()
{
$this->addColumn()
->setField('test');
$this->addColumn()
->setField('test');
}
```

Expand All @@ -42,8 +42,8 @@ Usage:
```php
public function setupGrid()
{
$this->addColumn()
->setIndex('r.test');
$this->addColumn()
->setIndex('r.test');
}
```

Expand All @@ -57,8 +57,8 @@ Usage:
```php
public function setupGrid()
{
$this->addColumn()
->setTwig('TestBundle:Test:template.html.twig')
$this->addColumn()
->setTwig('TestBundle:Test:template.html.twig')
->setFilterType(false);
}
```
Expand All @@ -79,8 +79,8 @@ Usage:
```php
public function setupGrid()
{
$this->addColumn()
->setSortable(false);
$this->addColumn()
->setSortable(false);
}
```

Expand Down
6 changes: 3 additions & 3 deletions Resources/doc/column/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Usage:
```php
public function setupGrid()
{
$this->addColumn()
->setFilterType('text');
$this->addColumn()
->setFilterType('text');
}
```

Expand All @@ -37,7 +37,7 @@ Operator:
```php
public function setupGrid()
{
$this->addColumn('ID')
$this->addColumn('ID')
->getFilter()
->getOperator()
->setComparisonType('equal');
Expand Down
4 changes: 2 additions & 2 deletions Resources/doc/column/render.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Usage:
```php
public function setupGrid()
{
$this->addColumn()
->setRenderType('text');
$this->addColumn()
->setRenderType('text');
}
```

Expand Down

0 comments on commit 4d04058

Please sign in to comment.