Magento – Remove column customer grid with observer

adminhtmlcustomerevent-observergridmagento-1.9

I'm trying to remove some columns from customer grid, but is not working, I've tried several similar events, but none of them work.

my config.xml

<adminhtml>
    <events>
        <core_block_abstract_to_html_before>
            <observers>
                <manage_adminhtml>
                    <class>manage_adminhtml/observer</class>
                    <method>getCustomerGrid</method>
                </manage_adminhtml>
            </observers>
        </core_block_abstract_to_html_before>
    </events>
</adminhtml>

and my observer

class Manage_Adminhtml_Model_Observer
{
    public function getCustomerGrid( $observer )
    {
        $block = $observer->getEvent()->getBlock();

        if ($block->getId() == 'customerGrid') {

            $block->removeColumn('group');
            $block->removeColumn('email');

            $block->sortColumnsByOrder();
        }
    }
}

Best Answer

What you want to do can be achieved with GridControl.

We use the event adminhtml_block_html_before and then call $params->getBlock()->removeColumn($params->getColumn()->getName());

Related Topic