incorporate DatatablesNet, using twig and stimulus, twig_component requires ^2.2

Installs: 1 749

Dependents: 0

Suggesters: 1

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Open Issues: 2


1.5.103 2023-12-03 20:36 UTC

This package is auto-updated.

Last update: 2023-12-03 20:36:54 UTC


Use the javascript library with Symfony, Twig and API Platform. requires survos/grid-bundle, which loads the datatables libraries.

composer req survos/api-grid-bundle


Import the datasets at

Dev only...

composer config repositories.survos_grid_bundle '{"type": "vcs", "url": ""}'


Inorder to use api-grid we need to follow below:

1) Add Survos\CoreBundle\Traits\QueryBuilderHelperTrait in your repository class of the entity for which you want apiGrid

2) you need to set columns variable like below:

        {% set columns = [
        {name: 'code', sortable: true},
        {name: 'countrycode', sortable: true,  browsable: true, searchable: true},
        {name: 'privacyPolicy', browsable: true},
        {name: 'projectLocale', browsable: true},
        ] %}

By default, sortable, browsable, searchable are false.

For those columns you want sortable add sortable: true

For those columns you want to add searchPanes add browsable: true

For those columns you want to add searchable: true

3) For search you need to include below

use Survos\ApiGrid\Api\Filter\MultiFieldSearchFilter;

#[ApiFilter(MultiFieldSearchFilter::class, properties: ['name', 'code'])]

Here name and code are columns in which you need to search

4) Use below for doctrine searchpane filters

First, make sure you have the necessary counts method by adding the helper trait to the repository class

class OfficialRepository extends ServiceEntityRepository implements QueryBuilderHelperInterface
    use QueryBuilderHelperTrait;

Then add the filterable properties to the entity class. You may want to index them to speed up the count query

use Survos\ApiGrid\Api\Filter\FacetsFieldSearchFilter;

#[ApiFilter(FacetsFieldSearchFilter::class, properties: ['gender','state'])]

5) Use below for doctrine order filters

use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;

#[ApiFilter(OrderFilter::class, properties: ['id','objectCount','countryCode'])]