liquidlab-agency / magento2-multiline-grid
Magento 2 module that preserves line breaks in text area custom attributes when displayed in the admin product grid.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 1
Open Issues: 0
Language:JavaScript
Type:magento2-module
Requires
- magento/framework: *
This package is not auto-updated.
Last update: 2025-06-03 04:12:09 UTC
README
This module provides a solution for displaying multiline text in Magento 2 admin grids. It preserves line breaks in text area custom attributes when displayed in the admin product grid.
Before and After
Before
After
Installation
To install the module via Composer:
composer require liquidlab-agency/magento2-multiline-grid
After installation:
- The module is already installed in your Magento 2 instance.
- After making any changes to the module, you need to deploy the static content and clear the cache:
bin/magento setup:upgrade bin/magento setup:di:compile bin/magento setup:static-content:deploy -f bin/magento cache:clean bin/magento cache:flush
Usage
The module automatically applies to all columns in the admin grid. No additional configuration is needed in your UI component XML.
How It Works
The module uses a mixin approach to:
- Extend the default Magento UI column functionality
- Convert newlines (
\n
) to HTML<br>
tags - Use Knockout's
html
binding instead oftext
binding to preserve HTML formatting
This ensures that line breaks in text area fields are properly displayed in the admin grid without requiring any changes to your UI component XML files.
Technical Details
The module follows Magento's best practices for mixins:
- The
requirejs-config.js
file is placed in theview/adminhtml
directory - It defines a mixin for the
Magento_Ui/js/grid/columns/column
component - The mixin overrides the
getLabel
method to convert newlines to<br>
tags 4The mixin sets thebodyTmpl
to use a custom template with thehtml
binding using the mapped path:bodyTmpl: 'Liquidlab_MultilineGrid/grid/cells/multiline'
This approach automatically applies to all columns in the admin grid, making it a more elegant solution than creating a custom column type.
After making changes to the module, always run the deployment commands listed in the Installation section to ensure the changes take effect. This is especially important when modifying RequireJS configurations and template paths.