i have a custom admin module will print some data
$this->addColumn('product_old_values', array(
 'header' => Mage::helper('adminlog')->__('product_old_values'),
 'align' =>'left',
 'width' => '20%',
 'index' => 'product_old_values',
)); 
since product_old_values is a serialized array (a long string), how can i run unserialize(product_old_values) before displaying into a grid?
 asked May 5, 2015 at 6:41
 
 
 
 hkguile 
 
 2,2416 gold badges47 silver badges89 bronze badges
 
 1 Answer 1
render the column by below code
$this->addColumn('product_old_values', array(
 'header' => Mage::helper('adminlog')->__('product_old_values'),
 'align' =>'left',
 'renderer' => 'Namespace_Modulename_Block_Adminhtml_Gridrender',
 'width' => '20%',
 'index' => 'product_old_values',
)); 
FOR RENDERING
class Namespace_Modulename_Block_Adminhtml_Gridrender extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
 {
 public function render(Varien_Object $row)
 {
 }
 }
for doing in grid class
 $this->addColumn('product_old_values', array(
 'header' => Mage::helper('adminlog')->__('product_old_values'),
 'align' =>'left', 
 'width' => '20%',
 'index' => 'product_old_values',
 'frame_callback' => array($this, 'callback_image')
 ));
public function callback_image($value)
 {
 //write your code
 }
 answered May 5, 2015 at 7:16
 
 
 
 Qaisar Satti 
 
 32.6k18 gold badges88 silver badges138 bronze badges
 
 - 
 is it a must to open another class? can i do it in grid class?hkguile– hkguile2015年05月06日 01:55:54 +00:00Commented May 6, 2015 at 1:55
- 
 you can do it with 'frame_callback' => array($this, 'callback_image') public function callback_image($value) { $width = 20; $height = 20; return "<img src='".Mage::getBaseUrl('media').$value."' width=".$width." height=".$height."/>"; } i used it for imageQaisar Satti– Qaisar Satti2015年05月06日 04:51:19 +00:00Commented May 6, 2015 at 4:51
- 
 i update the answer..Qaisar Satti– Qaisar Satti2015年05月06日 04:58:47 +00:00Commented May 6, 2015 at 4:58
- 
 @QaisarSatti can we return custom HTML in callback_image() method ?Dhaval Solanki– Dhaval Solanki2019年05月01日 06:00:24 +00:00Commented May 1, 2019 at 6:00
- 
 @dhavalsolanki yesQaisar Satti– Qaisar Satti2019年05月01日 06:04:37 +00:00Commented May 1, 2019 at 6:04
default