0

I've created a custom column in the report using UI components that use DataProvider in report_listing.xml Unfortunately, this new custom column is not able to sort.

I made also a class for this column which extended Column class Ui\Component\Listing\Column\testColumn::applySorting() to change sorting but this method is only using existing columns from sales_order. I'm only able to sort via existing in sales_order columns.

protected function applySorting()
 {
 $sorting = $this->getContext()->getRequestParam('sorting');
 $isSortable = $this->getData('config/sortable');
 if ($isSortable !== false
 && !empty($sorting['field'])
 && !empty($sorting['direction'])
 && $sorting['field'] === $this->getName()
 ) {
 $this->getContext()->getDataProvider()->addOrder(
 'custom_column',
 strtoupper($sorting['direction'])
 );
 }
 }

If there is no possibility to somehow made it like that, maybe I can kinda set values for a new column in another way to make possible sorting.

asked Feb 22, 2022 at 18:44
1
  • please share your xml code so I will check it quickly and easy to for your solution. Commented Feb 23, 2022 at 6:00

1 Answer 1

0

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 Feb 23, 2022 at 6:04

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.