3

Is there a built-in column renderer for that, or should I build one myself?

2 Answers 2

2

As you can see in the customer grid, there is an internal column renderer Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Country.

2
  • I'm just not sure if Mage::app()->getLocale()->getCountryTranslation($country_code) will get the whole name or simply does CSV translations.
    – Vicary
    Jul 24, 2015 at 10:23
  • ANY OTHER CHANGED REQUIRED ?
    – Gem
    Jan 19, 2017 at 9:44
0

Add a folder GRID/FILTER/COUNTRY from your grid.php folder

Add a file Country.php with the following code:

class YourComapny_YourModule_Block_Adminhtml_YourGridName_Grid_Filter_Country extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Select
{

protected function _getOptions()
    {
        $options = Mage::getResourceModel('directory/country_collection')->load()->toOptionArray();
        array_unshift($options, array('value'=>'', 'label'=>$this->__('All countries')));
        return $options;
    }
}

In your Grid.php set the country column to:

    $this->addColumn(
        'country_code',
        array(
            'header'=> $this->__('Country Code'),
            'width' => '5px',
            'type'  => 'country',
            'index' => 'country_code'
        )
    );

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.