Last active
December 13, 2015 00:49
-
-
Save tobias-forkel/c5f34f25f2e6fc60822d to your computer and use it in GitHub Desktop.
Use a block in your grid column renderer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Namespace ModuleName | |
* | |
* @category Namespace | |
* @package Namespace_ModuleName | |
* @copyright Copyright (c) 2015 Tobias Forkel (http://www.tobiasforkel.de) | |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | |
*/ | |
class Namespace_ModuleName_Block_Adminhtml_Item_Grid extends Mage_Adminhtml_Block_Widget_Grid | |
{ | |
/** | |
* Prepare grid columns | |
* | |
* @return Namespace_ModuleName_Block_Adminhtml_Item_Grid | |
*/ | |
protected function _prepareColumns() | |
{ | |
$this->addColumn('is_active', | |
array( | |
'header' => $this->__('Active'), | |
'index' => 'is_active', | |
'renderer' => 'Namespace_ModuleName_Block_Adminhtml_Item_Renderer_IsActive' | |
) | |
); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Namespace ModuleName | |
* | |
* @category Namespace | |
* @package Namespace_ModuleName | |
* @copyright Copyright (c) 2015 Tobias Forkel (http://www.tobiasforkel.de) | |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | |
*/ | |
class Namespace_ModuleName_Block_Adminhtml_Item_Renderer_IsActive extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract | |
{ | |
/** | |
* Render | |
* | |
* @param Varien_Object $row | |
* | |
* @return string | |
*/ | |
public function render(Varien_Object $row) | |
{ | |
return $this->getLayout()->createBlock('namespace/modulename/adminhtml_item_cell_isActive')->setRow($row)->toHtml(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Namespace ModuleName | |
* | |
* @category Namespace | |
* @package Namespace_ModuleName | |
* @copyright Copyright (c) 2015 Tobias Forkel (http://www.tobiasforkel.de) | |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | |
*/ | |
class Namespace_ModuleName_Block_Adminhtml_Entity_Cell_IsActive extends Mage_Adminhtml_Block_Widget_Form | |
{ | |
protected function _construct() | |
{ | |
parent::_construct(); | |
$this->setTemplate('namespace/modulename/adminhtml/item/cell/isactive.phtml'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $row = $this->getRow(); ?> | |
<strong>The content for your grid cell. Do something with $row.</strong> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment