2

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

1 Answer 1

2

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
7
  • is it a must to open another class? can i do it in grid class? Commented 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 image Commented May 6, 2015 at 4:51
  • i update the answer.. Commented May 6, 2015 at 4:58
  • @QaisarSatti can we return custom HTML in callback_image() method ? Commented May 1, 2019 at 6:00
  • @dhavalsolanki yes Commented May 1, 2019 at 6:04

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.