### Example: Configure Inline Edit Text Inputs Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/row-export.md This example demonstrates how to chain multiple `addText` calls to configure text inputs for inline editing, specifying keys and labels. ```php $inlineEdit = $grid->addInlineEdit('id') ->addText('name', 'Name') ->addText('email', 'Email'); ``` -------------------------------- ### Default Datagrid Configuration Example Source: https://github.com/contributte/datagrid/blob/master/_autodocs/configuration.md A complete example of setting up a Datagrid component in a Presenter factory method. This includes data sources, columns, filters, sorting, pagination, state management, actions, and localization. ```php // In Presenter factory method protected function createComponentGrid(): Datagrid { $grid = new Datagrid(); // Data $grid->setDataSource(new NetteDatabaseTableDataSource($this->db->table('users'))); $grid->setPrimaryKey('id'); // Columns $grid->addColumnText('id', 'ID') ->setSortable(); $grid->addColumnText('name', 'Name') ->setSortable() ->setFilterText(); $grid->addColumnText('email', 'Email') ->setFilterText(); $grid->addColumnLink('name', 'name', 'Detail', 'User:detail', ['id' => 'id']); // Filters $grid->addFilterText('search', 'Search', 'name'); $grid->addFilterSelect('status', 'Status', ['active' => 'Active', 'inactive' => 'Inactive']); // Sorting $grid->setSortable(true); $grid->setDefaultSort(['created_at' => 'DESC']); // Pagination $grid->setPagination(true); $grid->setDefaultPerPage(20); $grid->setItemsPerPageList([10, 20, 50, 100, 'all']); // State $grid->setRememberState(true); $grid->setAutoSubmit(true); // Actions $grid->addAction('detail', 'View', 'User:detail') ->setIcon('eye'); $grid->addActionCallback('delete', 'Delete', function ($id) { $this->db->query('DELETE FROM users WHERE id = ?', $id); }) ->setIcon('trash') ->setConfirmation(new StringConfirmation('Really delete?')); // Multi-select $grid->addMultiAction('delete', 'Delete Selected') ->setCallback(function ($ids) { foreach ($ids as $id) { $this->db->query('DELETE FROM users WHERE id = ?', $id); } }); // Localization $grid->setTranslator(new SimpleTranslator()); return $grid; } ``` -------------------------------- ### Install Datagrid with Composer Source: https://github.com/contributte/datagrid/blob/master/README.md Use Composer to install the latest version of the datagrid package. ```bash composer require ublaboo/datagrid ``` -------------------------------- ### Example: Configure Inline Add Text Inputs Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/row-export.md This example shows how to configure multiple text inputs for inline row addition, including setting default empty values for each. ```php $inlineAdd = $grid->addInlineAdd() ->addText('name', 'Name', '') ->addText('email', 'Email', ''); ``` -------------------------------- ### Example: Define Inline Add Callback Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/row-export.md This example demonstrates how to set a callback for the inline add operation, which inserts new user data into the database using the provided form values. ```php $inlineAdd->setCallback(function ($values) { db()->insert('users', $values); }); ``` -------------------------------- ### DibiFluentDataSource Example Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datasource.md Instantiate DibiFluentDataSource with a Dibi Fluent query builder instance. Ensure Dibi is configured with a connection. ```php $dibi = Dibi::getConnection(); $query = $dibi->select('*')->from('users')->where('status = ?', 'active'); $dataSource = new DibiFluentDataSource($query); $grid->setDataSource($dataSource); ``` -------------------------------- ### ElasticsearchDataSource Example Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datasource.md Initialize ElasticsearchDataSource with an Elasticsearch client instance and the index name. Requires the Elasticsearch client to be built. ```php $client = ClientBuilder::create()->build(); $dataSource = new ElasticsearchDataSource($client, 'users'); $grid->setDataSource($dataSource); ``` -------------------------------- ### Set Filter Value Example Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/filter.md Demonstrates how to set a filter's value using the `setValue` method. ```php $filter->setValue('active'); ``` -------------------------------- ### Setup Pagination & State Source: https://github.com/contributte/datagrid/blob/master/_autodocs/README.md Enable pagination with a default number of items per page and configure state persistence in the session. ```php $grid->setPagination(true)->setDefaultPerPage(20); $grid->setRememberState(true); // Persists in session ``` -------------------------------- ### DoctrineCollectionDataSource Example Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datasource.md Initialize DoctrineCollectionDataSource with a Doctrine Collection. This data source handles in-memory filtering. ```php $user = $em->find('App\Entity\User', 1); $dataSource = new DoctrineCollectionDataSource($user->getOrders()); $grid->setDataSource($dataSource); ``` -------------------------------- ### Get Available Items Per Page Options Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Use `getItemsPerPageList()` to get an array of all available items-per-page options configured for the datagrid. ```php public function getItemsPerPageList(): array ``` -------------------------------- ### Get Inline Add Instance Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Retrieve the configured inline add instance using `getInlineAdd`. Returns null if not set up. ```php $grid->getInlineAdd(); ``` -------------------------------- ### Require Latest 6.x Version for Preparation Source: https://github.com/contributte/datagrid/blob/master/UPGRADE.md Before upgrading to 7.0.x, ensure your 6.x installation is up to date by requiring the latest 6.10 version. ```bash composer require contributte/datagrid:^6.10 ``` -------------------------------- ### NetteDatabaseDataSource Example Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datasource.md Instantiate NetteDatabaseDataSource with a Nette Database Result object and set it as the grid's data source. ```php $db = new Nette\Database\Connection(...); $result = $db->query('SELECT * FROM users WHERE status = ?', 'active'); $dataSource = new NetteDatabaseDataSource($result); $grid->setDataSource($dataSource); ``` -------------------------------- ### NextrasDataSource Example Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datasource.md Create a NextrasDataSource using a Nextras ORM QueryBuilder instance. This is suitable for integrating with Nextras ORM repositories. ```php $repository = $orm->getRepository(User::class); $qb = $repository->findAll(); $dataSource = new NextrasDataSource($qb); $grid->setDataSource($dataSource); ``` -------------------------------- ### Configure Submit Button Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/filter.md Example demonstrating how to set both the CSS class and text for the filter submit button using method chaining. ```php $grid->getFilterSubmitButton() ->setClass('btn btn-primary') ->setText('Filter'); ``` -------------------------------- ### Get Export Columns Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/row-export.md Retrieve the list of column keys that are currently configured for export. ```php public function getColumns(): array ``` -------------------------------- ### Configure Pluggable State Storage in v7.1.x Source: https://github.com/contributte/datagrid/blob/master/UPGRADE.md Configure the pluggable state storage system in v7.1.x to allow custom storage backends. Examples include using `SessionStateStorage`, `NoopStateStorage`, or a custom implementation like `RedisStateStorage`. ```php use Contributte\Datagrid\Storage\IStateStorage; use Contributte\Datagrid\Storage\SessionStateStorage; use Contributte\Datagrid\Storage\NoopStateStorage; // Default: Session-based storage (same as before) $grid->setStateStorage(new SessionStateStorage()); // Alternative: No persistence $grid->setStateStorage(new NoopStateStorage()); // Custom implementation class RedisStateStorage implements IStateStorage { public function saveState(string $key, mixed $value): void { // Your Redis implementation } public function loadState(string $key, mixed $defaultValue = null): mixed { // Your Redis implementation } public function deleteState(string $key): void { // Your Redis implementation } } $grid->setStateStorage(new RedisStateStorage()); ``` -------------------------------- ### Get Datagrid Data Source Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Retrieves the currently configured data source for the datagrid. ```php $grid->getDataSource(); ``` -------------------------------- ### DoctrineDataSource Example Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datasource.md Create a DoctrineDataSource using a Doctrine QueryBuilder instance. This supports automatic filtering, sorting, joins, and pagination. ```php $em = $container->getService('doctrine.em'); $qb = $em->createQueryBuilder() ->select('u') ->from('App\Entity\User', 'u'); $dataSource = new DoctrineDataSource($qb); $grid->setDataSource($dataSource); ``` -------------------------------- ### Configure Column Display Source: https://github.com/contributte/datagrid/blob/master/_autodocs/configuration.md Control column visibility, order, and export order. This example enables columns to be hidden, sets a specific display order for columns, and defines the order for exported data. ```php $grid->setColumnsHideable(true) ->setColumnsOrder(['id', 'name', 'email', 'actions']) ->setColumnsExportOrder(['name', 'email', 'created_at']); ``` -------------------------------- ### Set Export Columns Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/row-export.md Specify which columns to include in the export. This is useful for controlling the data that gets exported. ```php public function setColumns(array $columns): self ``` ```php $export->setColumns(['id', 'name', 'email']); ``` -------------------------------- ### Update Translation Keys Source: https://github.com/contributte/datagrid/blob/master/UPGRADE.md When migrating, verify that translation keys used for DataGrid messages have been updated to match the new library's keys. This example shows how to set up a translator with updated keys. ```php // Verify translation keys are updated $translator = new Nette\Localization\Translator([ 'contributte_datagrid.no_items' => 'No items found' ]); ``` -------------------------------- ### Change Datagrid Filter Form Method Source: https://github.com/contributte/datagrid/blob/master/_autodocs/configuration.md Set the Datagrid::$formMethod static property to 'get' to use the GET HTTP method for the filter form, which will display filters in the URL. ```php // Use GET method for filters (shows in URL) Datagrid::$formMethod = 'get'; ``` -------------------------------- ### Initialize Basic Datagrid Source: https://github.com/contributte/datagrid/blob/master/_autodocs/README.md Instantiate a Datagrid, set its data source, add a text column with sorting, and define an action. ```php $grid = new Datagrid(); $grid->setDataSource(new ArrayDataSource($data)); $grid->addColumnText('name', 'Name')->setSortable(); $grid->addAction('detail', 'View', 'Page:detail'); return $grid; ``` -------------------------------- ### Configure Filter Behavior Source: https://github.com/contributte/datagrid/blob/master/_autodocs/configuration.md Control filter submission behavior, set default filter values, and manage the rendering of filters. This example enables auto-submit, sets a default filter for 'status', and configures outer filter rendering with a specific column count. ```php $grid->setAutoSubmit(true) ->setDefaultFilter(['status' => 'active']) ->setOuterFilterRendering(true) ->setOuterFilterColumnsCount(4); ``` -------------------------------- ### Get Inline Edit Instance Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Retrieve the configured inline edit instance using `getInlineEdit`. Returns null if not set up. ```php $grid->getInlineEdit(); ``` -------------------------------- ### Get Column Summaries Instance Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Retrieves the current ColumnsSummary instance if column summaries are enabled. Returns null if no summary instance is available. ```php $grid->getColumnsSummary(); ``` -------------------------------- ### Get Filter Name Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/filter.md Retrieves the display label for this filter. ```php public function getName(): string ``` -------------------------------- ### Get Filter Key Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/filter.md Retrieves the unique identifier for this filter. ```php public function getKey(): string ``` -------------------------------- ### Initialize NetteDatabaseTableDataSource Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datasource.md Use this to set up a data grid with data from Nette Database. It requires a Nette Database Selection object. ```php $db = new Nette\Database\Connection(...); $users = $db->table('users'); $dataSource = new NetteDatabaseTableDataSource($users); $grid->setDataSource($dataSource); ``` -------------------------------- ### Get Filter Value Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/filter.md Retrieves the current value set for the filter. ```php public function getValue(): mixed ``` -------------------------------- ### getPaginator Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Get the paginator component instance. Returns null if pagination is disabled. ```APIDOC ## getPaginator ### Description Get the paginator component. ### Method ```php public function getPaginator(): ?DatagridPaginator ``` ### Response #### Success Response (?DatagridPaginator) - **DatagridPaginator|null** - The paginator or null if pagination disabled ``` -------------------------------- ### Initialize ArrayDataSource Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datasource.md Use this to set up a data grid with data from a PHP array. The array can contain items as arrays or objects. ```php $data = [ ['id' => 1, 'name' => 'John', 'status' => 'active'], ['id' => 2, 'name' => 'Jane', 'status' => 'inactive'], ]; $dataSource = new ArrayDataSource($data); $grid->setDataSource($dataSource); ``` -------------------------------- ### Get Rows from CsvDataModel Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/row-export.md Fetch all the data rows stored within the `CsvDataModel`. ```php public function getRows(): array ``` -------------------------------- ### getParentComponent Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Gets the parent component of the datagrid, which is typically the Presenter in a Nette Framework application. ```APIDOC ## getParentComponent ### Description Get the parent component (usually Presenter). ### Method ```php public function getParentComponent(): Component ``` ### Returns `Component` - The parent component ``` -------------------------------- ### Get Header from CsvDataModel Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/row-export.md Retrieve the header row, which consists of column names, from the `CsvDataModel`. ```php public function getHeader(): array ``` -------------------------------- ### Instantiate and Use SimpleTranslator Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/storage-utilities.md Demonstrates how to instantiate SimpleTranslator with initial translations and set it on a grid object. This is useful for localizing grid column headers or other text elements. ```php $translator = new SimpleTranslator([ 'Name' => 'Jméno', 'Email' => 'E-mail', ]); $grid->setTranslator($translator); ``` -------------------------------- ### Configure Inline Add Source: https://github.com/contributte/datagrid/blob/master/_autodocs/configuration.md Set up inline adding for grid items, defining text fields and a callback for data insertion. ```php $inlineAdd = $grid->addInlineAdd(); $inlineAdd->addText('name', 'Name', '') ->addText('email', 'Email', '') ->setCallback(function ($values) { db()->insert('users', $values); }); ``` -------------------------------- ### Get Primary Key Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Retrieves the name of the primary key column currently set for the datagrid. ```php public function getPrimaryKey(): string ``` -------------------------------- ### Catch DatagridColumnException Source: https://github.com/contributte/datagrid/blob/master/_autodocs/errors.md Shows how to catch a DatagridColumnException, which is thrown for general column-related configuration errors. This is important for debugging issues with column setup, type mismatches, or property access. ```php try { $grid->render(); } catch (DatagridColumnException $e) { echo "Column configuration error: " . $e->getMessage(); } ``` -------------------------------- ### Get Datagrid Template File Path Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Retrieves the path of the currently set template file for the datagrid. This is useful for debugging or dynamic template loading. ```php public function getTemplateFile(): string ``` -------------------------------- ### Get Current State Storage Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Retrieves the currently active state storage implementation for the Datagrid. ```php public function getStateStorage(): IStateStorage ``` -------------------------------- ### Configure Tree View Source: https://github.com/contributte/datagrid/blob/master/_autodocs/configuration.md Set up the DataGrid to display data in a tree structure, specifying methods for retrieving children and checking for their existence. ```php $grid->setTreeView( 'getChildren', // Method/property to get children 'hasChildren', // Method/property to check for children true, // Use callback 'category' // Category/parent column ); ``` -------------------------------- ### Get All Columns Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Retrieve all columns currently configured in the datagrid as an associative array, keyed by their identifiers. ```php public function getColumns(): array ``` ```php foreach ($grid->getColumns() as $key => $column) { echo $column->getName(); } ``` ``` -------------------------------- ### Configure Items Per Page Options Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Set the available options for items per page using `setItemsPerPageList()`. The `includeAll` parameter, defaulting to `true`, determines if an 'all' option is added. ```php public function setItemsPerPageList(array $itemsPerPageList, bool $includeAll = true): self ``` ```php $grid->setItemsPerPageList([10, 20, 50, 'all']); ``` -------------------------------- ### Get Filter Type Identifier Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/filter.md Use getType to retrieve the identifier for the filter's type. ```php public function getType(): ?string ``` -------------------------------- ### Create and Configure GroupButtonAction Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/action.md Instantiate a GroupButtonAction with a key and label, then set its CSS class and callback function. The callback receives the selected IDs. ```php $action = new GroupButtonAction('key', 'Label'); $action->setClass('btn btn-warning') ->setCallback(function ($ids) { ... }); ``` -------------------------------- ### Get Parent Component Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Retrieves the parent component of the datagrid, which is typically the Presenter in a Nette Framework application. ```php public function getParentComponent(): Component ``` -------------------------------- ### Datagrid Constructor Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Creates a new Datagrid instance. It accepts an optional parent container and component name. ```php public function __construct(?IContainer $parent = null, ?string $name = null): void ``` -------------------------------- ### Get Current Page - DatagridPaginator Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/row-export.md Retrieves the current page number of the datagrid. The page number is 1-based. ```php public function getPage(): int ``` -------------------------------- ### handleShowAllColumns Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Signal handler automatically invoked by Nette to display all available columns in the datagrid. ```APIDOC ## handleShowAllColumns ### Description Signal handler to show all columns. Invoked automatically by Nette. ### Method ```php public function handleShowAllColumns(): void ``` ``` -------------------------------- ### Get Underlying Data Item Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/row-export.md Returns the original data item associated with the row, which can be an array or an object. ```php public function getItem(): mixed { // ... implementation details } ``` ```php $item = $row->getItem(); if (is_object($item)) { echo $item->getName(); } ``` -------------------------------- ### Get Filter Condition Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/filter.md Abstract method to be implemented by subclasses to define the data source condition for the filter. ```php abstract public function getCondition(): array ``` -------------------------------- ### Include Datagrid Assets (v6.0.x) Source: https://github.com/contributte/datagrid/blob/master/UPGRADE.md Include the necessary CSS and JavaScript files for Datagrid, which now requires Bootstrap 4+. ```html ``` -------------------------------- ### Apply Pagination (Offset and Limit) Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datasource.md Applies offset and limit to the data for pagination. Returns self for method chaining. ```php public function limit(int $offset, int $limit): self ``` ```php $dataSource->limit(20, 10); // Skip 20, return 10 ``` -------------------------------- ### Trigger DatagridActionCallbackException Source: https://github.com/contributte/datagrid/blob/master/_autodocs/errors.md This example demonstrates an action callback that throws a generic Exception, which will be caught and re-thrown as a DatagridActionCallbackException. ```php $grid->addActionCallback('delete', 'Delete', function ($id) { throw new Exception("Delete failed"); // becomes DatagridActionCallbackException }); ``` -------------------------------- ### Datagrid Constructor Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Initializes a new instance of the Datagrid component. It accepts an optional parent container and a component name. ```APIDOC ## Constructor Creates a new Datagrid instance. ### Signature ```php public function __construct(?IContainer $parent = null, ?string $name = null): void ``` ### Parameters - **parent** (IContainer|null) - Optional - Parent container component. - **name** (string|null) - Optional - Component name. ``` -------------------------------- ### Include Datagrid Assets (v5.x) Source: https://github.com/contributte/datagrid/blob/master/UPGRADE.md Include the necessary CSS and JavaScript files for Datagrid with Bootstrap 3 support. ```html ``` -------------------------------- ### Trigger DatagridArrayDataSourceException Source: https://github.com/contributte/datagrid/blob/master/_autodocs/errors.md This example shows how a custom sort callback returning a non-array value can trigger a DatagridArrayDataSourceException. ```php $dataSource = new ArrayDataSource($data); $column->setSortableCallback(function ($data, $sort) { return "invalid"; // Not an array - throws exception }); ``` -------------------------------- ### Get Filter Submit Button Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Retrieves the configuration object for the submit button of the datagrid's filter form. ```php public function getFilterSubmitButton(): SubmitButton ``` -------------------------------- ### Verify Asset Loading Paths Source: https://github.com/contributte/datagrid/blob/master/UPGRADE.md Ensure that the CSS and JavaScript files for the DataGrid are linked with the correct paths in your HTML. This is crucial for the grid to render and function properly. ```html ``` -------------------------------- ### Get Session Section Name Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Retrieves the session section name used for storing the Datagrid's state. ```php public function getSessionSectionName(): string ``` -------------------------------- ### Get Signal Handler for Sorting Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Retrieves the currently configured signal handler name used for sorting operations. ```php public function getSortableHandler(): string ``` -------------------------------- ### Find Files Using Old Namespace Source: https://github.com/contributte/datagrid/blob/master/UPGRADE.md Use the grep command to find all files within the 'src/' directory that still reference the old Ublaboo\DataGrid namespace. This helps identify areas needing namespace updates. ```bash # Find all files using old namespace grep -r "Ublaboo\\DataGrid" src/ ``` -------------------------------- ### NoopStateStorage Implementation Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/storage-utilities.md A no-operation state storage that does not persist any data. Use this when stateless behavior is desired, ensuring a fresh grid on every request. ```php $grid->setStateStorage(new NoopStateStorage()); // No state persisted - fresh grid on every request ``` -------------------------------- ### Get Data Items Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datasource.md Retrieves the actual data items to be displayed in the datagrid. The data can be an array or any Traversable object. ```php public function getData(): iterable ``` ```php $items = $dataSource->getData(); foreach ($items as $item) { echo $item['name']; } ``` -------------------------------- ### FilterSelect Usage Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/filter.md Illustrates how to implement a dropdown filter with predefined options, allowing users to select from a list of values. Includes configuration for the prompt text. ```APIDOC ## addFilterSelect ### Description Adds a dropdown filter to the datagrid with predefined options. ### Constructor Signature `__construct(Datagrid $grid, string $key, string $name, array $options, ?string $column = null)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **grid** (Datagrid) - Required - Parent datagrid. - **key** (string) - Required - Filter key. - **name** (string) - Required - Filter label. - **options** (array) - Required - [value => label] pairs. - **column** (string|null) - Optional - Column to filter (defaults to key). ### Example ```php $grid->addFilterSelect('status', 'Status', $options) ->setPrompt('All statuses'); ``` ## setPrompt ### Description Sets the placeholder text that appears in the dropdown when no option is selected. ### Method `setPrompt(string $prompt): self` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **prompt** (string) - Required - Prompt text. ### Example ```php $grid->addFilterSelect('status', 'Status', $options) ->setPrompt('All statuses'); ``` ``` -------------------------------- ### Show Inline Add Form Handler Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md The `handleShowInlineAdd` method is an automatic Nette signal handler used to display the inline add form. ```php $grid->handleShowInlineAdd(); ``` -------------------------------- ### PHP Datagrid getItemsDetail Method Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Retrieves the configuration for the item detail view. Returns the ItemDetail instance or null if not configured. ```php public function getItemsDetail(): ?ItemDetail ``` -------------------------------- ### FilterRange Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/filter.md Numeric range filter with from/to inputs. Allows setting custom conditions for the start and end of the range. ```APIDOC ## FilterRange Numeric range filter with from/to inputs. ### Methods #### setConditionFrom Set condition for range start (from value). - **condition** (string): Required - Operator (default: >=) #### setConditionTo Set condition for range end (to value). - **condition** (string): Required - Operator (default: <=) ``` -------------------------------- ### getItemsDetail Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Retrieves the configuration for the item detail view. This method allows you to get the current settings for how item details are displayed. ```APIDOC ## getItemsDetail ### Description Get the item detail view configuration. ### Method GET ### Endpoint /datagrid/itemDetail ### Returns #### Success Response (200) - **detail** (ItemDetail|null) - The item detail instance or null ``` -------------------------------- ### Configure Column Summary Source: https://github.com/contributte/datagrid/blob/master/_autodocs/configuration.md Define column summaries with aggregation functions (sum, avg) and an optional row filter. ```php $grid->setColumnsSummary(['price', 'quantity'], function ($row) { return $row['status'] === 'paid'; }) ->add('price', 'sum') ->add('quantity', 'avg'); ``` -------------------------------- ### Instantiate ApiDataSource Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datasource.md Use this to create a data source that fetches data from an external API. Provide a callable that accepts filter, sort, offset, and limit parameters and returns data. ```php use Contributte\Datagrid\DataSource\ApiDataSource; $dataSource = new ApiDataSource(function ($filter, $sort, $offset, $limit) { // Call external API $response = file_get_contents( 'https://api.example.com/users?filter=' . urlencode(json_encode($filter)) ); return json_decode($response, true); }); $grid->setDataSource($dataSource); ``` -------------------------------- ### handleShowInlineAdd Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Handles the signal to display the inline add form, typically invoked automatically by the Nette framework. ```APIDOC ## handleShowInlineAdd ### Description Signal handler to show inline add form. Invoked automatically by Nette. ### Method ```php public function handleShowInlineAdd(): void ``` ``` -------------------------------- ### Configure Pagination Settings Source: https://github.com/contributte/datagrid/blob/master/_autodocs/configuration.md Enable or disable pagination, set the default number of items per page, and define the list of available page size options. Use this to control how data is paginated and presented to the user. ```php $grid->setPagination(true) ->setDefaultPerPage(25) ->setItemsPerPageList([10, 25, 50, 100, 'all']); ``` -------------------------------- ### Get Custom Filter Condition Callback Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/filter.md Use getConditionCallback to retrieve the currently set custom filter condition callback. ```php public function getConditionCallback(): ?callable ``` -------------------------------- ### Get Sort Configuration Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/storage-utilities.md Retrieves the current sort configuration as a column-to-direction mapping. Useful for understanding the active sorting state. ```php public function getSort(): array { // ... implementation details ... } ``` ```php $sort = $sorting->getSort(); // ['name' => 'ASC', 'created_at' => 'DESC'] ``` -------------------------------- ### Configure Item Detail View Source: https://github.com/contributte/datagrid/blob/master/_autodocs/configuration.md Specify a template for item detail views and configure form elements within the detail view. ```php $grid->setItemsDetail(__DIR__ . '/templates/user-detail.latte', 'id'); $grid->setItemsDetailForm(function (Container $container) { $container->addText('bio', 'Biography:'); }); ``` -------------------------------- ### Data Source Configuration Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Methods for setting and retrieving the data source for the datagrid. ```APIDOC ## setDataSource ### Description Set the data source for the datagrid. Accepts arrays, DataSource objects, or Nette components. ### Method `setDataSource(mixed $source): self` ### Parameters #### Path Parameters - **source** (IDataSource|array|null) - Required - Data source implementation ### Throws - `DatagridWrongDataSourceException` - When source is invalid ### Example ```php $grid->setDataSource($db->query('SELECT * FROM users')); // or $grid->setDataSource($users); // array ``` ``` ```APIDOC ## getDataSource ### Description Get the current data source. ### Method `getDataSource(): IDataSource|array|null` ### Returns - `IDataSource|array|null` - The configured data source ``` -------------------------------- ### Set Date Range Filter Condition From Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/filter.md Sets the comparison operator for the start date in a date range filter. Defaults to '>='. ```php public function setConditionFrom(string $condition): self ``` ```php $filter->setConditionFrom('>='); ``` -------------------------------- ### Configure Filters & Sorting Source: https://github.com/contributte/datagrid/blob/master/_autodocs/README.md Add a text filter for searching, enable general sorting, and set a default sort order. ```php $grid->addFilterText('search', 'Search', 'name')->setPlaceholder('Enter name...'); $grid->setSortable(true); $grid->setDefaultSort(['created_at' => 'DESC']); ``` -------------------------------- ### Configure Select Filter in Datagrid Source: https://github.com/contributte/datagrid/blob/master/_autodocs/configuration.md Add a select (dropdown) filter with predefined options and a prompt for the default selection. ```php $grid->addFilterSelect('status', 'Status', [ 'active' => 'Active', 'inactive' => 'Inactive', ]) ->setPrompt('All statuses'); ``` -------------------------------- ### Get Column Count - PHP Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Retrieve the total number of columns currently configured in the datagrid. This can be used for validation or display purposes. ```php public function getColumnsCount(): int ``` ```php echo $grid->getColumnsCount(); // 5 ``` -------------------------------- ### Accessing and Saving Session State Keys Source: https://github.com/contributte/datagrid/blob/master/_autodocs/configuration.md Demonstrates how to retrieve specific session data and save custom data using the Datagrid's storage methods. Useful for persisting grid-specific information. ```php $grid->getStorageData('_grid_hidden_columns'); $grid->saveStorageData('_grid_custom_key', $value); ``` -------------------------------- ### handleShowDefaultColumns Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Signal handler automatically invoked by Nette to display the default set of columns in the datagrid. ```APIDOC ## handleShowDefaultColumns ### Description Signal handler to show default columns. Invoked automatically by Nette. ### Method ```php public function handleShowDefaultColumns(): void ``` ``` -------------------------------- ### Get Column by Key Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Retrieve a specific column instance from the datagrid using its unique key. Throws an exception if the column is not found. ```php public function getColumn(string $key): Column ``` ```php $nameColumn = $grid->getColumn('name'); ``` ``` -------------------------------- ### Get Total Page Count - DatagridPaginator Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/row-export.md Retrieves the total number of pages available in the datagrid. This is useful for displaying pagination controls. ```php public function getPageCount(): int ``` -------------------------------- ### Add Column Summary Calculation Source: https://github.com/contributte/datagrid/blob/master/_autodocs/types.md Configure column summary calculations like sum, average, or count. Specify the column name, the renderer for the summary, and optional replacements. ```php class ColumnsSummary { public function add(string $column, string $renderer, array $replacements = []): self; } ``` -------------------------------- ### Get HTML Placeholder Attribute Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/filter.md Retrieve the current value of the HTML placeholder attribute for a filter. Returns null if no placeholder is set. ```php $grid->getPlaceholder(); ``` -------------------------------- ### Retrieve an Action by Key Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Use getAction to fetch an existing action, whether it's a single row action or a multi-row action, using its unique key. ```php public function getAction(string $key): Action|MultiAction ``` ```php $action = $grid->getAction('detail'); ``` -------------------------------- ### Get Row CSS Classes Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/row-export.md Retrieves a string containing all space-separated CSS classes applied to the row's `` element. ```php public function getControlClass(): string { // ... implementation details } ``` ```php $class = $row->getControlClass(); // 'row-highlight active' ``` -------------------------------- ### Action Constructor Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/action.md Initializes a new Action column. It requires the parent Datagrid instance, a unique key, a display name, and an optional link destination. ```APIDOC ## Constructor ```php public function __construct( Datagrid $grid, string $key, string $name, ?string $href = null ) ``` ### Parameters #### Path Parameters - **grid** (Datagrid) - Required - Parent datagrid - **key** (string) - Required - Unique action identifier - **name** (string) - Required - Button/link text - **href** (string|null) - Optional - Link destination ``` -------------------------------- ### Get Row HTML Element Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/row-export.md Generates and returns the HTML `` element for the row. Allows for further manipulation of the element's attributes. ```php public function getControl(): Html { // ... implementation details } ``` ```php $tr = $row->getControl(); $tr->setAttribute('class', 'highlight'); ``` -------------------------------- ### Configure Link Column to Open in New Tab Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/column.md Set whether the link should open in a new browser tab or window. ```php $column->setOpenInNewTab(true); ``` -------------------------------- ### Get Total Item Count Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datasource.md Retrieves the total number of items available in the data source. Use this to display pagination information. ```php public function getCount(): int ``` ```php $count = $dataSource->getCount(); echo "Total items: $count"; ``` -------------------------------- ### Configure Inline Row Addition Source: https://github.com/contributte/datagrid/blob/master/_autodocs/types.md Class for configuring the addition of new rows inline within the grid. Allows setting default values and callbacks. ```php class InlineAdd { public function addText(string $key, string $name, mixed $defaultValue = ''): self; public function setCallback(callable $callback): self; // Additional form control methods } ``` -------------------------------- ### SessionStateStorage Implementation Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/storage-utilities.md The default implementation for persisting datagrid state using PHP sessions. It requires a Nette SessionSection instance. ```php $session = $container->getService('session'); $section = $session->getSection('datagrid_' . $gridName); $storage = new SessionStateStorage($section); $grid->setStateStorage($storage); ``` -------------------------------- ### addFilterDateRange Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Adds a date range filter to the datagrid. This filter allows users to specify a start and end date for filtering records. ```APIDOC ## addFilterDateRange ### Description Add a date range filter. ### Method Signature ```php public function addFilterDateRange(string $key, string $name, ?string $column = null, ?string $columnTo = null): FilterDateRange ``` ### Parameters #### Path Parameters - **key** (string) - Required - Unique filter identifier - **name** (string) - Required - Filter label text - **column** (string|null) - Optional - Column name for range start - **columnTo** (string|null) - Optional - Column name for range end ### Returns `FilterDateRange` — The date range filter instance ### Example ```php $grid->addFilterDateRange('created', 'Created Between', 'created_from', 'created_to'); ``` ``` -------------------------------- ### Configure Column Summaries Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/row-export.md Add column summaries to the datagrid, specifying the column key, the desired renderer (e.g., 'sum', 'avg'), and optional value replacements. This method supports method chaining. ```php $grid->setColumnsSummary(['price', 'quantity']) ->add('price', 'sum') ->add('quantity', 'avg'); ``` -------------------------------- ### Set Datagrid Data Source Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Configures the data source for the datagrid. Accepts arrays, DataSource objects, or Nette components. Returns the datagrid instance for chaining. ```php $grid->setDataSource($db->query('SELECT * FROM users')); // or $grid->setDataSource($users); // array ``` -------------------------------- ### Get Sortable Parent Path Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Obtains the parent path string used for identifying sortable elements within the datagrid's structure. ```php public function getSortableParentPath(): string ``` -------------------------------- ### Get Full Component Name Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Retrieves the complete name of the datagrid component, typically used for generating HTML element IDs and names. ```php public function getFullName(): string ``` -------------------------------- ### Configure Item Detail Template Source: https://github.com/contributte/datagrid/blob/master/_autodocs/types.md Use this class to define the template for expandable detail rows in a datagrid. The template is specified as a string. ```php class ItemDetail { public function setTemplate(string $template): self; } ``` -------------------------------- ### Configure CSV Export Source: https://github.com/contributte/datagrid/blob/master/_autodocs/configuration.md Enable and configure CSV export for the grid, specifying columns and a confirmation dialog. ```php if ($grid->csvExport) { $grid->addExport('csv', 'Export CSV') ->setColumns(['id', 'name', 'email']) ->setConfirmDialog('Export data?'); } ``` -------------------------------- ### Get Datagrid Paginator Component Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Obtain the paginator component instance using `getPaginator()`. This returns the `DatagridPaginator` object or `null` if pagination is disabled. ```php public function getPaginator(): ?DatagridPaginator ``` -------------------------------- ### Get Default Sort for a Column Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Retrieves the default sort direction (ASC/DESC) configured for a specific column. Returns null if no default is set. ```php public function getColumnDefaultSort(string $columnKey): ?string ``` -------------------------------- ### render Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/row-export.md Renders the export button as a Nette Html element, making it ready to be displayed in the UI. ```APIDOC ## render ### Description Render the export button as HTML. ### Method `render(): Html` ### Returns `Html` - Nette Html element ``` -------------------------------- ### Get Value from State Storage Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/storage-utilities.md Use this method to retrieve a previously stored value. Provide a default value to be returned if the key is not found. ```php $value = $storage->getValue('datagrid_users', '_grid_hidden_columns', []); ``` -------------------------------- ### Add Action to Datagrid Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/action.md Adds a new action to the datagrid with a key, name, and optional URL. This is the initial step before configuring other action properties. ```php $grid->addAction('detail', 'View', 'User:detail'); ``` -------------------------------- ### Get Custom Template Variables Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/column.md Retrieves the array of variables that are passed to the custom column template. This is useful for debugging or inspecting template data. ```php public function getTemplateVariables(): array ``` -------------------------------- ### Configure Link Column Icon Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/column.md Set a Font Awesome icon to be displayed before the link text in a ColumnLink. ```php $grid->addColumnLink('name', 'name', 'Name', 'User:detail', ['id' => 'id']) ->setIcon('eye'); ``` -------------------------------- ### Configure State Persistence Source: https://github.com/contributte/datagrid/blob/master/_autodocs/configuration.md Enable state persistence to remember user interactions like filters, sorting, and pagination. This snippet also configures the URL to update when the state changes. ```php $grid->setRememberState(true, true) // Remember filters, sorting, pagination, column visibility ->setRefreshUrl(true); ``` -------------------------------- ### Get Next Sort State Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/column.md Calculate and return the sort state that will be applied on the next click. This helps in implementing interactive sorting controls. ```php // If sorted ASC, returns ['columnKey' => 'DESC'] // If sorted DESC, returns ['columnKey' => 'ASC'] // If not sorted, returns ['columnKey' => 'ASC'] ``` -------------------------------- ### Get Custom Sorting Callback Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/column.md Retrieve the currently set custom sorting callback for a column. Returns null if no custom callback is defined. ```php public function getSortableCallback(): ?callable ``` -------------------------------- ### handleShowColumn Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Signal handler automatically invoked by Nette to display a specific column identified by its key. ```APIDOC ## handleShowColumn ### Description Signal handler to show a specific column. Invoked automatically by Nette. ### Method ```php public function handleShowColumn(string $column): void ``` ### Parameters #### Path Parameters - **column** (string) - Required - Column key ``` -------------------------------- ### Configure Date Range Filter in Datagrid Source: https://github.com/contributte/datagrid/blob/master/_autodocs/configuration.md Add a date range filter. Specify the conditions for the start and end dates and the date format. ```php $grid->addFilterDateRange('created', 'Created Between', 'created_from', 'created_to') ->setConditionFrom('>=') ->setConditionTo('<=') ->setFormat('yyyy-mm-dd'); ``` -------------------------------- ### GroupAction Source: https://github.com/contributte/datagrid/blob/master/_autodocs/types.md Configuration for bulk group actions. Allows setting a callback function to be executed and a CSS class for styling. ```APIDOC ## Class GroupAction ### Description Configuration for bulk group actions. Allows setting a callback function to be executed and a CSS class for styling. ### Namespace `Contributte\Datagrid\GroupAction` ### Location `src/GroupAction/GroupAction.php` ### Methods #### setCallback(callable $callback): self Sets the callback function to be executed for the group action. #### setClass(string $class): self Sets the CSS class for the group action. ``` -------------------------------- ### Get Column Value Callback Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Retrieves the callback function associated with a specific column key. Returns null if no callback is set for the given column. ```php $grid->getColumnCallback('column_key'); ``` -------------------------------- ### Create Datagrid Paginator Component Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md The `createComponentPaginator()` method is a factory for the paginator component, intended for use by Nette's dependency injection system. ```php public function createComponentPaginator(): DatagridPaginator ``` -------------------------------- ### CsvDataModel Class Source: https://github.com/contributte/datagrid/blob/master/_autodocs/types.md Class for building CSV data structures. It provides methods to add rows, retrieve the header, and get all rows for CSV export. ```APIDOC ## CsvDataModel Class ### Description Build CSV data structure. ### Methods - `addRow(array $row): self` - `getHeader(): array` - `getRows(): array` ### Namespace `Contributte\Datagrid` ### Location `src/CsvDataModel.php` ``` -------------------------------- ### StringConfirmation Class Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/action.md A simple implementation of IConfirmation that uses a static string message for confirmation. ```APIDOC ## StringConfirmation ### Description Simple string confirmation dialog. ### Constructor ```php public function __construct(string $message) ``` #### Parameters - **message** (string) - Required - Confirmation message ### Example ```php $confirmation = new StringConfirmation('Delete this user?'); $action->setConfirmation($confirmation); ``` ``` -------------------------------- ### Configure Export Handler Source: https://github.com/contributte/datagrid/blob/master/_autodocs/types.md Class for configuring data export options. Allows setting columns, callbacks, and appearance for exports. ```php class Export { public function __construct( Datagrid $grid, string $text, callable $callback, bool $filtered ); public function setColumns(array $columns): self; public function getColumns(): array; public function setLink(Link $link): self; public function setAjax(bool $ajax = true): self; public function isAjax(): bool; public function setConfirmDialog(string $confirmDialog): self; public function setTarget(string $target): self; public function setTitle(string $title): self; public function setIcon(string $icon): self; public function setClass(string $class): self; public function setText(string $text): self; public function render(): Html; } ``` -------------------------------- ### Get Items Per Page - DatagridPaginator Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/row-export.md Retrieves the configured limit for the number of items displayed on each page of the datagrid. This value dictates the pagination granularity. ```php public function getItemsPerPage(): int ``` -------------------------------- ### addReplacement Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/storage-utilities.md Adds a value replacement for rendering. This allows you to map original values to display values, for example, mapping numeric codes to human-readable strings. ```APIDOC ## addReplacement ### Description Add value replacement for rendering. ### Method ```php public function addReplacement(mixed $from, mixed $to): self ``` ### Parameters #### Path Parameters - **from** (mixed) - Required - Original value - **to** (mixed) - Required - Display value ### Request Example ```php $column->addReplacement(1, 'Active') ->addReplacement(0, 'Inactive'); ``` ### Returns `self` - For method chaining ``` -------------------------------- ### Update PHP and Datagrid to v7.0.x Source: https://github.com/contributte/datagrid/blob/master/UPGRADE.md Update your PHP version to 8.2+ and then require the datagrid v7.0.x. ```bash # Update PHP to 8.2+ composer require php:^8.2 # Update to 7.0.x composer require contributte/datagrid:^7.0 ``` -------------------------------- ### Set Custom Template File for Datagrid Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Use this method to specify a custom template file for rendering the datagrid. This allows for complete customization of the grid's appearance. ```php public function setTemplateFile(string $templateFile): self ``` ```php $grid->setTemplateFile(__DIR__ . '/custom-grid.latte'); ``` -------------------------------- ### Add Date Range Filter Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Adds a date range filter to the datagrid. Specify the key, label, and optionally the start and end column names. ```php public function addFilterDateRange(string $key, string $name, ?string $column = null, ?string $columnTo = null): FilterDateRange ``` ```php $grid->addFilterDateRange('created', 'Created Between', 'created_from', 'created_to'); ``` -------------------------------- ### Set Button Icon Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/row-export.md Configure the button with a Font Awesome icon. This method allows for chaining. ```php public function setIcon(string $icon): self ``` -------------------------------- ### FilterDateRange Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/filter.md Date range filter with two date pickers. Allows setting custom conditions for the start and end dates, and configuring the date format. ```APIDOC ## FilterDateRange Date range filter with two date pickers. ### Methods #### setConditionFrom Set condition for start date. - **condition** (string): Required - Operator (default: >=) #### setConditionTo Set condition for end date. - **condition** (string): Required - Operator (default: <=) #### setFormat Set date format for JavaScript date picker. - **format** (string): Required - Date format ``` -------------------------------- ### Configure Multi-Select Filter in Datagrid Source: https://github.com/contributte/datagrid/blob/master/_autodocs/configuration.md Add a multi-select filter allowing users to choose multiple options from a list. Set a prompt for the default state. ```php $grid->addFilterMultiSelect('tags', 'Tags', [ 'tag1' => 'Tag 1', 'tag2' => 'Tag 2', ]) ->setPrompt('Select tags...'); ``` -------------------------------- ### Get Row Condition Callback Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Retrieve a previously set row condition callback by its name. Optionally, specify an action or multi-action key for specific conditions. ```php public function getRowCondition(string $name, ?string $key = null): bool|callable ``` -------------------------------- ### Get Total Item Count - DatagridPaginator Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/row-export.md Retrieves the total number of items that the datagrid is currently displaying or managing. This count is essential for calculating pagination ranges. ```php public function getItemCount(): int ``` -------------------------------- ### Check if Filters Match Defaults Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/datagrid.md Verifies if the current filter settings exactly match the predefined default filter values. ```php public function isFilterDefault(): bool ``` -------------------------------- ### Custom Column Rendering with Callback Source: https://github.com/contributte/datagrid/blob/master/_autodocs/api-reference/action.md Define a custom rendering callback for a column to dynamically format its values. The callback receives the current row and should return the desired output. ```php $column->setRenderer(function (Row $row) { $value = $row->getValue('status'); return $value === 'active' ? 'Active' : 'Inactive'; }); ```