3

How can I perform the same logic of filter_condition_callback of Magento 1 in Magento 2

I have a country column which I save comma separated values in db I have managed to create the filter but I am not able to get the result the values are stored comma separated.

How can I apply filter_condition_callback to get the result.

0

You can do it same as magento1, inside grid.php file,

You can reference for used of filter_conditions_callback from core file,

magento/vendor/magento/module-catalog/Block/Adminhtml/Product/Edit/Tab/Crosssell.php

Now set inside grid.php file

class Grid{
      //logic for class...
        $this->addColumn(
                    'position',
                    [
                        'header' => __('Position'),
                        'name' => 'position',
                        'type' => 'number',                
                        'index' => 'position',               
                        'filter_condition_callback' => [$this, 'filterCustom']
                    ]
                );

        public function filterCustom($collection, $column)
            {
                //here you can set your conditions using find_in_set mysql condtions
                return $this;
            }
}
  • How do I apply it in ui-component grid ? – Priyank Nov 15 '16 at 11:35
  • @Priyank did you figure it out? how to add condition filter to ui-component grid? – karthi keyan May 14 '18 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.