I got stuck into the magento admin grid. I need to put the filter on the grid column. which has value YES and NO.

But YES and NO are decided from the many conditions. I have one renderer file for delivering the value for column and in that file there are lots of conditions. By passing through lots of conditions I have decided that particular row should have YES/No or BLANK.

And I don't know how to put a filter above the column. I cant put the same logic to the filter callback as there are already around 200 lines conditions have been put to the renderer files.

Please suggest a way to achieve this.

Thank you.

Here is my code Grid.php

$this->addColumn('mailSent', array(
        'header'            => Mage::helper('vendor')->__('Other Updates'),
        'renderer'          => 'Namesapce_Modulename_Block_Adminhtml_Vendor_Order_Renderer_Mailsent',
        'option'            => $this->getVendorIds(),
        'type'              => 'options',
        'options'           => Mage::getModel('vendor/vendor')->getOptionArray(),
        'column_css_class'  => 'mailsent-td',
        'width'             => '4px'
  • Put your code which you are trying Jul 2, 2018 at 6:28
  • @RahulSingh I have edited the question. Please let me know if you want renderer file code. You can imagine the renderer file with many conditions and in results it returns YES/NO/BLANK. as per requirement.
    – Mansi Raja
    Jul 2, 2018 at 6:52
  • The code must be adding column "Other Updates" and with the option (filter) on grid, Till here you getting or not ? Jul 2, 2018 at 6:56
  • Yes I am getting the column values perfectly having dropdown to the the top saying YES/NO.. I dont know how to make this dropdown working. like selecting yes - it should return the rows having YES only.
    – Mansi Raja
    Jul 2, 2018 at 7:01
  • have you checked Renderer file is it working ? Jul 2, 2018 at 7:04

1 Answer 1


Use filter callback like below:

'filter_condition_callback' => array($this, '_myCustomFilter')

And add this function to your grid.php file and put the conditions according to your requirement.

protected function _myCustomFilter($collection, $column)
    if (!$value = $column->getFilter()->getValue()) {
        return $this;

        "my_field like ?"
    , "%$value%");

    return $this;
  • Thanks for the answer but I cant do this as my column value is not based on the collection . I cant get grid values for that particular column by simply putting "where conditions". I m having lots of conditions and then its decided that YES/NO value for the column..
    – Mansi Raja
    Jul 2, 2018 at 10:14
  • You need to join the queries. Jul 2, 2018 at 10:50
  • result is not bases on DB - there are some constant declared and other array manipulations with color code for every status. which increases line of code at renderer file
    – Mansi Raja
    Jul 2, 2018 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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