Can I show json data I pull from some api in admin grid? Currently I tried to create varien data collection. But its not working. Any help is highly appreciated.
class Company_Module_Block_Adminhtml_Poll_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
protected function _prepareCollection()
{
$collection = new Varien_Db_Collection();
if ( Mage::registry('json_data') )
{
$data=json_decode(Mage::registry('json_data'));
foreach ($data as $row) {
$rowObj = new Varien_Object();
$rowObj->setData($row);
$collection->addItem($rowObj);
}
}
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('id', array(
'type'=>'text',
'index'=>'id',
'header'=>$this->__('Print Id')
));
$this->addColumn('customer_email', array(
'type'=>'text',
'index'=>'customer_email',
'header'=>$this->__('Customer Email')
));
return parent::_prepareColumns();
}
}