digitalstate/platform-datagrid-bundle
Installation:
composer require digitalstate/platform-datagrid-bundle
Add to config/bundles.php:
return [
// ...
DigitalState\PlatformDataGridBundle\DigitalStatePlatformDataGridBundle::class => ['all' => true],
];
First Use Case:
Extend an existing OroDataGrid grid or create a new one by configuring a data source in your custom bundle.
Example: Override oro_datagrid.datagrid.your_entity in config/packages/your_bundle.yaml:
oro_datagrid:
grids:
your_entity:
source:
acl_resource: 'your_entity_view'
type: 'orm'
query:
select: ['e.id', 'e.name']
from: ['{YourBundle:Entity} e']
Key Files to Explore:
Resources/config/oro/datagrid.yml (default configurations)DependencyInjection/Extension.php (bundle extension points)EventListener/ (event-driven hooks for customization)Data Source Customization:
Oro\ORM\DataGrid\ORMDataGridProvider for complex queries.$queryBuilder->andWhere('e.status = :status')->setParameter('status', 'active');
Column Configuration:
columns:
id:
label: 'ID'
frontend_type: 'integer'
name:
label: 'Name'
frontend_type: 'string'
editable: true
Event-Driven Extensions:
oro_datagrid.build.query.before or oro_datagrid.build.result.after:
public function onBuildQueryBefore(GridBuildQueryBeforeEvent $event) {
$event->getQueryBuilder()->leftJoin('e.relatedEntity', 're');
}
Integration with Forms:
oro_datagrid.edit_form and oro_datagrid.view_form to bind grids to edit/view forms:
oro_datagrid:
grids:
your_entity:
edit_form:
form_type: 'YourBundle\Form\Type\YourEntityType'
options:
data_class: 'YourBundle\Entity\Entity'
API/Export Integration:
oro_datagrid.export for CSV/Excel exports:
export:
enabled: true
formats: ['csv', 'xlsx']
ACL Resource Mismatches:
acl_resource in the grid config matches your Symfony security roles.bin/console debug:acl if grids fail to load.Query Performance:
SELECT *; explicitly define columns to reduce overhead.DQL for complex joins (e.g., WITH clauses) but test performance.Caching Issues:
php bin/console cache:clear
config/packages/dev/oro_datagrid.yaml:
oro_datagrid:
caching: false
Frontend Template Conflicts:
templates/oro_datagrid/ to customize rendering.{{ grid('your_entity') }} in Twig; avoid hardcoding IDs.Dynamic Column Visibility:
visible option with conditions:
columns:
advanced_field:
visible: '@=grid.getParameter("show_advanced")'
Bulk Actions:
actions for mass updates/deletes:
actions:
update:
type: 'update'
label: 'Update'
acl_resource: 'your_entity_update'
Debugging Queries:
.env:
APP_DEBUG=true
DATABASE_URL="mysql://user:pass@localhost/db?serverVersion=8.0&charset=utf8mb4&enable_query_log=true"
var/log/dev.log for generated DQL.Extension Points:
DigitalState\PlatformDataGridBundle\Provider\DataGridProvider for custom data sources.DigitalState\PlatformDataGridBundle\Event\GridEvents for pre/post-processing.Testing:
oro_datagrid.tester service in PHPUnit:
$this->get('oro_datagrid.tester')->loadGrid('your_entity');
How can I help you explore Laravel packages today?