0

I'm using Magento 2. So, I created a Adminhtml data grid in a custom module. The problem is that the data grid doesn't match the exported data. I've set the timezone, but it seems data grid and exported data use different time base.

Below is the code I use to show created_at attribute.

<column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date" component="Magento_Ui/js/grid/columns/date">
        <settings>
            <filter>dateRange</filter>
            <dataType>date</dataType>
            <label translate="true">Created At</label>
            <sorting>asc</sorting>
        </settings>
    </column>

Tell me if you need more information regarding this problem. Any hint is appreciated. Thanks!

  • please share your 'created_at' column xml code. – Faisal Sheikh Aug 29 '19 at 7:24
  • Please check the updated question @FaisalSheikh – user7414328 Aug 29 '19 at 7:39
  • please try below code. – Faisal Sheikh Aug 29 '19 at 7:43
0

Please try below code for created_at column:

<column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="filter" xsi:type="string">dateRange</item>
                <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
                <item name="dataType" xsi:type="string">date</item>
                <item name="label" xsi:type="string" translate="true">Created at</item>
            </item>
        </argument>
    </column>

Hope it's help you.

|improve this answer|||||
  • It doesn't work. Exportbutton is supposed to be using what data grid has, is that correct? – user7414328 Aug 29 '19 at 7:50
  • Yes, it's working on my side. – Faisal Sheikh Aug 29 '19 at 7:53
  • Unfortunately it doesn't work on my side. Thank you for trying anyway! Cheers – user7414328 Aug 29 '19 at 8:02
0

I've found an answer for this problem. Please do comment if there's anything wrong about this answer.

Basically we have to add metadataprovider configuration in

[ModuleName]/etc/adminhtml/di.xml

<type name="Magento\Ui\Model\Export\MetadataProvider">
    <arguments>
        <argument name="data" xsi:type="array">
            <item name="customer_note_listing" xsi:type="array">
                <item name="created_at" xsi:type="string">created_at</item>
            </item>
        </argument>
    </arguments>
</type>

This will register our component name which is then checked in convertDate method in

Magento/Module-Ui/Model/Export/MetadataProvider.php.

|improve this answer|||||

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.