5

How to filter drop-down in custom grid in my case its throwing error Below is my grid code

protected function _prepareColumns()
{        
    $this->addColumn('attribute', array(
        'header'    => Mage::helper('moduelname')->__('Test'),
        'align'     =>'left',
        'index'     => 'attribute',
        'type' => 'options',
        'renderer'  => 'ModuleName_Namespace_Block_Adminhtml_Renderer_Test',
        'options' => array(
            '0' => Mage::helper('moduelname')->__('Please Select'),
            '1' => Mage::helper('moduelname')->__('On Hold'),
            '2' => Mage::helper('moduelname')->__('Credit Hold'),
            '3' => Mage::helper('moduelname')->__('Open'),
        ),
    ));
    return parent::_prepareColumns();
}

protected function _prepareCollection()
{
    $collection = Mage::getModel('sales/order_status')->getResourceCollection();
    $this->setCollection($collection);
    return parent::_prepareCollection();
}

ERROR:

a:5:{i:0;s:203:"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'attribute' in 'where clause', query was: SELECT COUNT(*) FROM sales_order_status AS main_table WHERE (attribute = '1')";i:1;s:5177:"#0 /var/www/test /lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)

7
  • shoe more details
    – Amit Bera
    Feb 27, 2015 at 10:32
  • isnt it just replacing "attribute" with your actual attribute name? Feb 27, 2015 at 11:01
  • Please show more details. Specifically the _prepareCollection function. Feb 27, 2015 at 11:39
  • I edited Question please take a look
    – Magento AJ
    Feb 27, 2015 at 12:40
  • Its giving error because there is no any field or attribute in your collection please check you collection first. Feb 27, 2015 at 12:46

1 Answer 1

0
options' => array('Please Select', 'On Hold' => 'On Hold', 'Credit Hold' => 'Credit Hold', 'Open' => 'Open')

Why don't you just put each label as string? This worked fine for me.

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.