I want to sort custom rendere column in magento grid.
See below image--
As in above image Sorting is done using Status column, but it is is showing wrong. I want to sort it like active
,on hold
,out of stock
.
Here is the code in Grid.php--
$this->addColumn('stock_status', array(
'header' => Mage::helper('allstock')->__('Status'),
'width' => '200px',
'align' => 'center',
'index' => 'stock_status',
'renderer' => 'allstock/adminhtml_allstock_renderer_stockstatus'
));
here is the renderer code-
public function render(Varien_Object $row)
{
$stock_status=$row->getStockStatus();
if($stock_status=='stock on hold')
{
$html="on hold";
}
else
{
$html=$stock_status;
}
return $html;
}