Filter & Sorting Not Working for custom column course_category_name in ui_component grid & custom column data render from another table through multiple table joins in Magento 2
Our DataProvider code is given below. If anyone has any solution, please give it to me.
collection = $collectionFactory->create(); $this->categoryCollection = $categoryCollectionFactory->create(); $this->addFieldStrategies = $addFieldStrategies; $this->addFilterStrategies = $addFilterStrategies; $this->localeCurrency = $localeCurrency; $this->storeManager = $storeManager; $this->context = $context; } /** * Get data * * @return array */ public function getData() { if (!$this->getCollection()->isLoaded()) { $this->getCollection()->load(); } $categoryResourceModel = $this->categoryCollection->getResource(); $this->getCollection()->getSelect()->join( ['xcc' => $categoryResourceModel->getTable('xteam_category_courses')], "main_table.course_id = xcc.course_id", ['xcc.course_category_id'] )->join( ['xccat' => $categoryResourceModel->getTable('xteam_course_categories')], 'xcc.course_category_id = xccat.course_category_id', [ 'course_category_id' => new Zend_Db_Expr('GROUP_CONCAT(DISTINCT xcc.course_category_id ORDER BY xcc.course_category_id)'), 'course_category_name' => new Zend_Db_Expr('GROUP_CONCAT(DISTINCT xccat.course_category_name ORDER BY xcc.course_category_id)') ] )->group('main_table.course_id'); $items = $this->getCollection()->getData(); // echo ""; print_r($items->getData()); exit; return [ 'totalRecords' => $this->getCollection()->getSize(), 'items' => array_values($items), ]; } }