<commit_before>Grid configurations
===================

## Handle multiple grids on the same page

You can set the identifier of your grid if you have more than one grid on your page.

```php
<?php
$grid = $this->get('grid');
$grid2 = $this->get('grid'); // or clone $grid;

$grid->setSource(new Entity('App\Name\Entity1'));
$grid->setId('first');

$grid2->setSource(new Entity('App\Name\Entity2'));
$grid2->setId('second');

if ($grid->isReadyForRedirect() || $grid2->isReadyForRedirect())
{
  return new RedirectResponse($this->generateUrl($this->getRequest()->get('_route')));
}
else
{
  return $this->render('App:Name:index.html.twig', array('data' => $grid->prepare(), 'data2' => $grid2->prepare()));
}
```

## Configure the pager
```php
<?php
// Set the selector of the number of items per page
$grid->setLimits(array(5 => '5', 10 => '10', 15 => '15'));

// Set the default page
$grid->setPage(2);

$grid->setSource($source);
```

## Add columns to the grid

A column must be defined after the source otherwise it will appear always before the columns of the source.
<commit_msg>Update docs: setId() needs to be defined before setting source<commit_after>Grid configurations
===================

## Handle multiple grids on the same page

You can set the identifier of your grid if you have more than one grid on your page.

```php
<?php
$grid = $this->get('grid');
$grid2 = $this->get('grid'); // or clone $grid;

$grid->setId('first');
$grid->setSource(new Entity('App\Name\Entity1'));

$grid2->setId('second');
$grid2->setSource(new Entity('App\Name\Entity2'));

if ($grid->isReadyForRedirect() || $grid2->isReadyForRedirect())
{
  return new RedirectResponse($this->generateUrl($this->getRequest()->get('_route')));
}
else
{
  return $this->render('App:Name:index.html.twig', array('data' => $grid->prepare(), 'data2' => $grid2->prepare()));
}
```

## Configure the pager
```php
<?php
// Set the selector of the number of items per page
$grid->setLimits(array(5 => '5', 10 => '10', 15 => '15'));

// Set the default page
$grid->setPage(2);

$grid->setSource($source);
```

## Add columns to the grid

A column must be defined after the source otherwise it will appear always before the columns of the source.

{'fraction_non_alphanumeric': 0.1996394772420009, 'fraction_numerical': 0.017124831004957188, 'mean_word_length': 5.235955056179775, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5197751', 'n_tokens_mistral': 722, 'n_tokens_neox': 696, 'n_words': 221}