3

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>
Magento Dev
1,2848 silver badges24 bronze badges
asked Aug 22, 2018 at 10:29
1
  • Please check my answer in this post. Hope it may help anyone. Commented Sep 5, 2021 at 6:34

2 Answers 2

2

Maybe this is already old question, but it can be helpful for someone like me facing this issue.

According to this Magento 2 GitHub issue there is a ui_bookmark table in which some settings about ui_components (and Grid in my case) are stored.

Truncating this table and clearing the cache in my case fixed the problem of columns sortOrder in Grid.

answered Nov 15, 2019 at 9:27
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

answered Aug 22, 2018 at 10:58
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. Commented Aug 22, 2018 at 11:38
  • @DavidCoder Did you ever find an answer to your question ? Commented Apr 14, 2021 at 7:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.