Column Types reference

Most important Grid definition part is defining columns. PrestaShop already comes with a list of predefined columns that you can use in your own Grids.

Supported Types

Basic columns

Action columns

Employee columns

Status columns

Use case example

<?php
// /modules/my-module/src/Grid/MyGridDefinitionFactory.php
namespace MyModule\Grid;

use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\AbstractGridDefinitionFactory;
use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn;
use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection;
use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn;
use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection;
use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction;

/**
 * How to define the Grid columns?
 * You can adapt this exemple or look at the existing ones
 * in PrestaShop Core.
 */
class MyGridDefinitionFactory extends AbstractGridDefinition
{
    /**
     * {@inheritdoc}
     */
    protected function getColumns()
    {
        return (new ColumnCollection())
            ->add(
                (new BulkActionColumn('delete_stuff'))
                ->setOptions([
                    'bulk_field' => 'id_stuff',
                ])
            )
            ->add(
                (new DataColumn('id_stuff'))
                ->setName('ID')
                ->setOptions([
                    'field' => 'id_stuff',
                ])
            )
            ->add(
                (new ActionColumn('actions'))
                ->setName('Actions')
                ->setOptions([
                    'actions' => (new RowActionCollection())
                    ->add(
                        (new LinkRowAction('delete'))
                        ->setIcon('delete')
                        ->setOptions([
                            'route' => 'delete_stuff',
                            'route_param_name' => 'stuffId',
                            'route_param_field' => 'id_stuff',
                            'confirm_message' => 'Delete selected item?',
                        ])
                    ),
                ])
            )
        ;
    }
}
You need to create a custom Column Type? We got you covered!