Question

Here i have to add filter in charity and fee column,if charity is filled then display in grid otherwise that data should not show in grid.

But all record's are displayed. I have 2 order in one order charity is applied. I want to display only that order wich charity is applied. please help..

Thank you.. Here i have 2 order in one order charity is applied. I want to display only that order wich charity is applied.

Was it helpful?

Solution

Add below code in 'Model/ResourceModel/Grid/Collection' file for filter grid

protected function _renderFiltersBefore()
{

   $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
   $request = $objectManager->get('Magento\Framework\App\Request\Http');
   $filters = $request->getParam("filters");
   if (isset($filters['product_id'])) {
       $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
       $product = $objectManager- >get('Magento\Catalog\Model\ProductFactory')->create()
        ->getCollection()
        ->addAttributeToFilter('sku', ['eq'=>$filters['product_id']])->getFirstItem();
    $this->getSelect()->orWhere("product_id = '" . $product->getId() .   "'");
 }
parent::_renderFiltersBefore();}   

But its not working for me.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top