If you have a look at the renderer for the column type radio, Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Radio
, you can see that there is no way to add an onclick
event listener:
public function render(Varien_Object $row)
{
$values = $this->getColumn()->getValues();
$value = $row->getData($this->getColumn()->getIndex());
if (is_array($values)) {
$checked = in_array($value, $values) ? ' checked="checked"' : '';
} else {
$checked = ($value === $this->getColumn()->getValue()) ? ' checked="checked"' : '';
}
$html = '<input type="radio" name="' . $this->getColumn()->getHtmlName() . '" ';
$html .= 'value="' . $row->getId() . '" class="radio"' . $checked . '/>';
return $html;
}
If you are looking to duplicate the functionality of the customer or product grid mass actions, have a look at the method Mage_Adminhtml_Block_Widget_Grid::_prepareMassactionColumn()
.
It adds a column with the type massaction
.
It is called automatically whenever you add a mass action to a grid, but can also be used independently.
Please add below changes to your code.
You need to add GROUP BY entity_id
.
Add select query on collection like below.
$collection->getSelect()->joinLeft(
array('s' => new Zend_Db_Expr('(SELECT (o.grand_total - o.tax_amount) grand_excl_tax,'
. ' FROM ' . Mage::getSingleton('core/resource')->getTableName('sales/invoice') . ' AS o'
. ' GROUP BY entity_id)')),
"s.entity_id = main_table.entity_id",
array('grand_excl_tax')
);
After that add filter_index
in addColumn
:
$this->addColumn('grand_excl_tax', array(
'header' => Mage::helper('customer')->__('Amount Excl. Tax'),
'index' => 'grand_excl_tax',
'filter_index' => 's.grand_excl_tax',
'type' => 'currency',
'align' => 'right',
'currency' => 'order_currency_code',
));
I am tested it and it's working fine form me, After applying this there is not any issue on grid filter.
Let me know still if you face any issue.
Best Answer
You column can look like this:
Basically, you can use
column_css_class
andheader_css_class
to add any CSS classes to the column and then work your magic in the CSS file. In Magento admin default themeno-display
class has 'display:none' on it.