Skip to content

Add a way to define a default query for the DataTableType#252

Open
alexandre-castelain wants to merge 9 commits into
Kreyu:mainfrom
fulgens-hq:default-query-in-datatable-type
Open

Add a way to define a default query for the DataTableType#252
alexandre-castelain wants to merge 9 commits into
Kreyu:mainfrom
fulgens-hq:default-query-in-datatable-type

Conversation

@alexandre-castelain
Copy link
Copy Markdown
Contributor

@alexandre-castelain alexandre-castelain commented Jan 26, 2026

Description

This Merge Request introduces documentation for handling the query option in DataTables. It explains how to define a default query within a DataTableType and how to override or extend it from a controller, providing flexibility similar to the Symfony Form component.

Default definition:

class ProductDataTableType extends AbstractDataTableType 
{
    public function getQuery(array $options): mixed
    {
        return $this->productRepository->createDefaultQueryBuilder();
    }
}

As soon as the getQuery method returns a value that can be handled by a class that implements ProxyQueryFactoryInterface, the code will work.

$dataTable = $this->createDataTable(ProductDataTableType::class);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants