In Magento 2, the ui_component
based grids allow you to reorder columns and Magento will remember your settings the next time you log in. This is accomplished by Magento saving data in the ui_bookmark
table (via a Magento\Ui\Model\Bookmark
model object).
While this feature it neat, it can create problems when a extension developer or system integrator uses Magento ui_component
XML to add columns to a table. If there's a custom data ui_bookmark
then Magento will (seemingly) ignore the sort order of a new column and weird/unexpected things can happen.
Is there a best practice and/or system for extension developers who want to add columns to a UI Grid (either Magento's or their own) and ensure a column is somewhere in relation to the others? i.e. -- "This second action button should always appear last, or always appear second last", or "the name field should always be after ID.
Does an extension developer need to, via an app/code/Package/Module/Setup/...
class, reach into the ui_bookmark
table and update these entries themselves? Or is there a better way to accomplish this? Or do extension developers just need to live with a column being added to unexpected places when a user already has an entry in ui_bookmark
?