1

I have created a custom grid using UI component. "Store" column is one of the columns.
The issue is, when there is Store column, export function is not working.
The error comes from the following path

vendor/magento/module-ui/Model/Export/MetadataProvider.php function: getRowData()

What I want to know is, whether there is an issue in my implementation or this is a Magento issue? Thanks

<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<argument name="data" xsi:type="array">
    <item name="js_config" xsi:type="array">
        <item name="provider" xsi:type="string">test_uploader_listing.test_uploader_listing_data_source</item>
    </item>
</argument>
<settings>
    <buttons>
        <button name="add">
            <url path="*/*/new"/>
            <class>primary</class>
            <label translate="true">Add New</label>
        </button>
    </buttons>
    <spinner>test_uploader_columns</spinner>
    <deps>
        <dep>test_uploader_listing.test_uploader_listing_data_source</dep>
    </deps>
</settings>
<dataSource name="test_uploader_listing_data_source" component="Magento_Ui/js/grid/provider">
    <settings>
        <storageConfig>
            <param name="indexField" xsi:type="string">test_id</param>
        </storageConfig>
        <updateUrl path="mui/index/render"/>
    </settings>
    <aclResource>test_test::test_manage</aclResource>
    <dataProvider class="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider" name="test_uploader_listing_data_source">
        <settings>
            <requestFieldName>id</requestFieldName>
            <primaryFieldName>test_id</primaryFieldName>
        </settings>
    </dataProvider>
</dataSource>
<listingToolbar name="listing_top">
    <settings>
        <sticky>true</sticky>
    </settings>
    <bookmark name="bookmarks"/>
    <columnsControls name="columns_controls"/>
    <exportButton name="export_button"/>
    <filterSearch name="fulltext"/>
    <filters name="listing_filters">
        <settings>
            <templates>
                <filters>
                    <select>
                        <param name="template" xsi:type="string">ui/grid/filters/elements/ui-select</param>
                        <param name="component" xsi:type="string">Magento_Ui/js/form/element/ui-select</param>
                    </select>
                </filters>
            </templates>
        </settings>
        <filterSelect name="store_id" provider="${ $.parentName }">
            <settings>
                <captionValue>0</captionValue>
                <options class="Magento\Cms\Ui\Component\Listing\Column\Cms\Options"/>
                <label translate="true">Store View</label>
                <dataScope>store_id</dataScope>
                <imports>
                    <link name="visible">componentType = column, index = ${ $.index }:visible</link>
                </imports>
            </settings>
        </filterSelect>
    </filters>
    <massaction name="listing_massaction">
        <action name="delete">
            <settings>
                <confirm>
                    <message translate="true">Are you sure you want to delete selected items?</message>
                    <title translate="true">Delete items</title>
                </confirm>
                <url path="test/icons/massDelete"/>
                <type>delete</type>
                <label translate="true">Delete</label>
            </settings>
        </action>
        <action name="disable">
            <settings>
                <url path="test/icons/massDisable"/>
                <type>disable</type>
                <label translate="true">Disable</label>
            </settings>
        </action>
        <action name="enable">
            <settings>
                <url path="test/icons/massEnable"/>
                <type>enable</type>
                <label translate="true">Enable</label>
            </settings>
        </action>
    </massaction>
    <paging name="listing_paging"/>
</listingToolbar>
<columns name="test_uploader_columns">
    <selectionsColumn name="ids">
        <settings>
            <indexField>test_id</indexField>
            <resizeEnabled>false</resizeEnabled>
            <resizeDefaultWidth>55</resizeDefaultWidth>
        </settings>
    </selectionsColumn>
    <column name="test_id" sortOrder="100">
        <settings>
            <filter>textRange</filter>
            <label translate="true">ID</label>
            <sorting>asc</sorting>
        </settings>
    </column>
    <column name="name" sortOrder="150">
        <settings>
            <filter>text</filter>
            <label translate="true">Name</label>
        </settings>
    </column>

    <column name="store_id" class="Magento\Store\Ui\Component\Listing\Column\Store">
        <settings>
            <label translate="true">Store View</label>
            <bodyTmpl>ui/grid/cells/html</bodyTmpl>
            <sortable>false</sortable>
        </settings>
    </column>
    <column name="status" component="Magento_Ui/js/grid/columns/select">
        <settings>
            <options class="Magento\Cms\Model\Block\Source\IsActive"/>
            <filter>select</filter>
            <editor>
                <editorType>select</editorType>
            </editor>
            <dataType>select</dataType>
            <label translate="true">Status</label>
        </settings>
    </column>        
    <actionsColumn name="actions" class="test\test\Ui\Component\Listing\Column\TestActions">
        <settings>
            <indexField>icon_id</indexField>
        </settings>
    </actionsColumn>
</columns>

collection file

vendor/mode/RsourceModel/Files/Collection

class Collection extends AbstractCollection

{  
protected $_idFieldName = 'test_id';

/**
 * Load data for preview flag
 *
 * @var bool
 */
protected $_previewFlag;

/**
 * Event prefix
 *
 * @var string
 */
protected $_eventPrefix = 'test_test_Grid_Collection';

/**
 * Event object
 *
 * @var string
 */
protected $_eventObject = 'test_Grid_Collection';

/**
 * _construct
 */
protected function _construct()
{
    $this->_init('test\test\Model\Files', 'test\test\Model\ResourceModel\Files');
    $this->_map['fields']['test_id'] = 'main_table.test_id';
    $this->_map['fields']['store'] = 'store_table.store_id';
}

/**
 * Set first store flag
 *
 * @param bool $flag
 * @return $this
 */
public function setFirstStoreFlag($flag = false)
{
    $this->_previewFlag = $flag;
    return $this;
}


public function addStoreFilter($store, $withAdmin = true)
{
    if (!$this->getFlag('store_filter_added')) {
        $this->performAddStoreFilter($store, $withAdmin);
    }
    return $this;
}

/**
 * Perform operations after collection load
 *
 * @return $this
 */
protected function _afterLoad()
{
    //$entityMetadata = $this->metadataPool->getMetadata(PageInterface::class);
    $this->performAfterLoad('test_store', 'test_id');
    $this->_previewFlag = false;

    return parent::_afterLoad();
}

/**
 * Perform operations before rendering filters
 *
 * @return void
 */
protected function _renderFiltersBefore()
{
    //$entityMetadata = $this->metadataPool->getMetadata(PageInterface::class);
    $this->joinStoreRelationTable('test_store', 'test_id');
}
  • please add your code – HIren Kadivar Mar 6 at 8:32
  • which code you are referring? My grid is working well. this is a basic grid.this happens when export is functioning – Kevin Mar 6 at 8:41
  • Ui-Component for export button and collection file – HIren Kadivar Mar 6 at 8:44
  • Hi @HIrenKadivar i have updated the post – Kevin Mar 6 at 9:01
  • add Collection.php – HIren Kadivar Mar 6 at 9:02

Your Answer

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

Browse other questions tagged or ask your own question.