Adminhtml Grid – Assign the Same Value to Column of Custom Grid

adminhtmlgrid

I want to assign the same text to one column of all rows of the Grid

I have my custom grid and I added column like this:

class Ailin_Orders_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
{  //somecode
     protected function _prepareColumns()
        {
            $helper = Mage::helper('ailin_orders');
            $this->addColumn('Vendor Code',
                array(
                    'header'=> Mage::helper('catalog')->__('Vendor Code'),
                    'width' => '50px',
                    'renderer'  => 'adminhtml/sales_render'
            ));
}
}

I created a file render.php to render the value simply like this:

class Ailin_Orders_Block_Adminhtml_Sales_Render
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
    public function render(Varien_Object $row)
    {
        return "SCOZAH";
    }
}

enter image description here

Best Answer

There's a mistake in how you're calling your renderer. Try this:

$this->addColumn('Vendor Code',
            array(
                'header'=> Mage::helper('catalog')->__('Vendor Code'),
                'width' => '50px',
                'renderer'  => 'ailin_orders/adminhtml_sales_render'
        ));
Related Topic