Important
You are browsing upcoming documentation for version 6.1 of OroCommerce, scheduled for release in 2025. Read the documentation for version 6.0 (the latest LTS version) to get up-to-date information.
See our Release Process documentation for more information on the currently supported and upcoming releases.
Datagrid Views List
Provides the ability to add a list of grid views. Adds filters and sorters from the grid view to the parameters’ filters.
To write your own view list, create a class that extends the Oro\Bundle\DataGridBundle\Extension\GridViews\AbstractViewsList
class. Here is an example:
<?php
namespace Acme\Bundle\DemoBundle\Datagrid;
use Oro\Bundle\DataGridBundle\Entity\GridView;
use Oro\Bundle\DataGridBundle\Extension\GridViews\AbstractViewsList;
use Oro\Bundle\FilterBundle\Form\Type\Filter\TextFilterType;
/**
* Grid views for acme-demo-favorite-grid datagrid.
*/
class FavoriteViewList extends AbstractViewsList
{
protected $systemViews = [
[
'name' => 'acme_demo.first_view',
'label' => 'acme.demo.favorite.datagrid.views.first_example_view_label',
'is_default' => false,
'grid_name' => 'acme-demo-favorite-grid',
'type' => GridView::TYPE_PUBLIC,
'filters' => [
'name' => [
'type' => TextFilterType::TYPE_EQUAL,
'value' => 'First favorite'
]
],
'sorters' => [
'name' => 'DESC'
],
'columns' => []
], [
'name' => 'acme_demo.sample_view',
'label' => 'acme.demo.favorite.datagrid.views.second_example_view_label',
'is_default' => false,
'grid_name' => 'acme-demo-favorite-grid',
'type' => GridView::TYPE_PUBLIC,
'filters' => [
'name' => [
'type' => TextFilterType::TYPE_STARTS_WITH,
'value' => 'Last'
]
],
'sorters' => [],
'columns' => [
'name' => ['renderable' => true, 'order' => 1],
'viewCount' => ['renderable' => true, 'order' => 2],
'value' => ['renderable' => true, 'order' => 3],
]
]
];
#[\Override]
protected function getViewsList()
{
return $this->getSystemViewsList();
}
}
Add the service definition to services.yml
:
services:
acme_demo.favorite_view_list:
class: Acme\Bundle\DemoBundle\Datagrid\FavoriteViewList
public: true
arguments:
- '@translator'
You can add the view list to the datagrid in the datagrids.yml file for a specified datagrid under the view-list node.
datagrids:
acme-demo-favorite-grid:
views_list: '@acme_demo.favorite_view_list'
Related Articles