While working with Magento 2 admin grids, it’s common to add custom columns to default grids such as the Product Grid, Order Grid, Customer Grid, etc.
For example, a store owner may want to add a custom column to the product grid i.e:”Stock Status” – to quickly identify whether a product is in stock or out of stock, without opening each record individually. This requires customizing the product grid to include a new column.
However, during such customizations, you might encounter issues where the newly added column appears at the end of the grid, even when a lower sortOrder value is specified or it doesn’t load properly, or issues arise after applying filters or sorting.
These problems typically occur due to how Magento 2 handles UI component grids.
Here’s what may be causing the issue:
- The column was added via a plugin or observer rather than directly within the UI component XML.
- The cache or static files were not properly cleared after making changes.
- UI component XML was overridden or merged in unexpected ways.
Solution to Fix the Grid Column Position Challenges
Start with deleting the entry of the affected grid from the ui_bookmark table.
In Magento 2, grid settings such as filters, column positions, and visibility are saved in the ui_bookmark table. Deleting the corresponding entry resets the grid to its default configuration.
Ensure your custom column has a correct and low sortOrder value in the UI component XML. Then, run these cache directories:
php bin/magento cache:flush
rm -rf generated/* var/view_preprocessed/* pub/static/*
php bin/magento setup:static-content:deploy
By following these steps, you can successfully fix custom column position issues in Magento 2 grid.
Need help implementing custom functionality in your Magento 2 store?
Explore our ready-made Magento 2 custom order grid module an advanced order grid to add, track and manage order information in one place for faster order processing and accurate order management.