Magento – Magento 1.9 admin grid linkable to custom .phtml file

adminhtmlcollection;gridmagento-1.9

I made a grid in admin for viewing all the applications received. I want to make a link in one column so when the admin clicks this link a new page will be opened. In this page I will pass the id and will fetch some data via collections.
Further I have made front end form and all tables have collections. Please advice weather it is good idea to use collection queries to fetch data from db tables in the phtml file or there is some alternative to this. Remember this is not single query this contains some joins etc also.

Thanks in advance.

Best Answer

You can add a link in action column easily. Just follow the standard procedure. Just add a new action in the actions array according to your requirements. As an example, checkout the below code:

$this->addColumn('action',
        array(
            'header'    =>  Mage::helper('your_module_name')->__('Actions'),
            'width'     => '100',
            'type'      => 'action',
            'getter'    => 'getId',
            'actions'   => array(
                array(
                    'caption'   => Mage::helper('your_module_name')->__('Print'),
                    'url'       => array('base'=> '*/*/print'),
                    'field'     => 'id'
                ),
                array(
                    'caption'   => Mage::helper('brands')->__('Edit'),
                    'url'       => array('base'=> '*/*/edit'),
                    'field'     => 'id'
                )
            ),
            'filter'    => false,
            'sortable'  => false,
            'index'     => 'stores',
            'is_system' => true,
    ));

If you are using collections to fetch data from your models, then its ok, and it does not create any problem related to performance. Also note that magento does not provide any way to pass data from your controllers to a view (except by some nasty ways). So one of the way to keep the MVC pattern is to use helper classes. Also, blocks can be used.