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.
-
please share your xml code so I will check it quickly and easy to for your solution.Bhavesh Godhani– Bhavesh Godhani2022年02月23日 06:00:55 +00:00Commented Feb 23, 2022 at 6:00
1 Answer 1
Please follow the link provided below to add sorting and filtering of custom column in grid:
Explore related questions
See similar questions with these tags.