1

I've created custom grid block using UI component but I can not export it to csv file.

I'm getting the error:

Undefined index: attributes in vendor\magento\framework\View\Element\UiComponentFactory.php on line 166

My module is here: https://github.com/helmsmantest/M2-Custom-grid

1
  • Your code looks legit. Try to remove parts from the ui component xml to to isolate the problem. Or check how $componentData looks like in UiComponentFactory::argumentsResolver, the method that reports the error.
    – Marius
    Feb 14 '18 at 15:23
4

You need to add a selections column element. See this example from sales_order_grid.xml (replace the indexField with the primary key from your model):

<selectionsColumn name="ids">
    <settings>
        <indexField>entity_id</indexField>
    </settings>
</selectionsColumn>
0

In your file pass the following selection column after <columns name="orders_list_columns">. https://github.com/helmsmantest/M2-Custom-grid/blob/master/app/code/BroSolutions/OrdersExport/view/adminhtml/ui_component/orders_list.xml

<selectionsColumn name="ids">
    <settings>
        <indexField>entity_id</indexField>
    </settings>
</selectionsColumn>

Also update exportButton tag

<exportButton name="export_button">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="selectProvider" xsi:type="string">orders_list.orders_list_columns.ids</item>
                </item>
            </argument>
        </exportButton>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.