0

I've successfully extended the core Customer Grid to show some custom attributes, but also need to remove the Country column - the site in question only operates in one country, so it's unnecessary and takes up space on smaller screens.

I've tried:

protected function _prepareColumns(){
    $this->removeColumn('billing_country_id'); // <---- this does not work :(
    $this->addColumnAfter('department', array(
        'header'    => Mage::helper('customer')->__('Department'),
        'index'     => 'department'
    ),'email');

    return parent::_prepareColumns();
}

but this does not seem to work. Is there another method that I can use?

1 Answer 1

0

Removing the column doesn't work because at the moment when you are calling the removeColumn method, the billing_country_id column hasn't been added yet. That column gets added when Mage_Adminhtml_Block_Customer_Grid::_prepareColumns is called, and that happens at the end of your method. You can try something like this:

protected function _prepareColumns() {
    parent::_prepareColumns();
    $this->removeColumn('billing_country_id'); // <--- hopefully this will work :)
    $this->addColumnAfter('department', array(
        'header'    => Mage::helper('customer')->__('Department'),
        'index'     => 'department'
    ), 'email');
    $this->sortColumnsByOrder();
    return $this;
}

I've also added the sortColumnsByOrder method call at the end in order to sort the newly added column too.

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.