Skip to content

Loading a grid / UI component based on url parameter

In magento 2.4.4. backend i have a use case where i have a select that chooses a object type [cms/page, cms/block, catalog/product, catalog/category, etc].

Based on this object type I would like to load a grid ui component for that object type since we have different fields and filters per object type.

Making the grids is not the problem, however, i cannot find anywhere how i can inject the right grid/uicomponent in my controller action based on the select’s request value.

Based on the value selected in the select, I want to show just one of each of these grids:

  <referenceContainer name="content">
    <uiComponent name="cms_block_grid"/>
    <uiComponent name="cms_page_grid"/>
    <uiComponent name="catalog_product_grid"/>
    <uiComponent name="catalog_category_grid"/>
    ..
</referenceContainer>

use case: All grids have a generic action that adds them to a (translation) queue.