2

I have created custom column in Sales -> Order UI Grid. I have added "Profit" column. Which is not related to any database table and not the attribute. This column display just calculation of profit.

The issue is I can not sort the column. Column is sortable but it is sorting incorrectly.

I have checked many similar question in stack but nothing helpfull. As the column is not in table and not the attribute.

Following is my override file.

sales_order_grid.xml

<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <columns name="sales_order_columns">
        <column name="total_paid" class="Company\Module\Ui\Component\Listing\Column\PurchasedPrice">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="label" xsi:type="string" translate="true">Profit</item>
                    <item name="sortOrder" xsi:type="number">13</item>
                </item>
            </argument>

        </column>
    </columns>
</listing>
0

I have faced this problem and below link helped me to get through it. Please follow the link provided below to add sorting and filtering of custom column in grid:

Custom Column Sorting in Admin Grid - Magento 2

  • Thanks but as I mentioned the column is not in any table. The data of the column is coming from on block where I calculate the profit and return the profit amount. So this link is not useful. – David Coder Aug 22 '18 at 11:38

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.