magento 根据管理网格中的条件显示内容
magento show content according to condition in admin grid
我开发了自定义管理模块。我使用常用方法 _prepareCollection
和 _prepareColumns
在 Grid 中显示数据。
protected function _prepareCollection()
{
$collection = Mage::getModel("wallets/sellerrequest")->getCollection();
$collection->getSelect()
->join( array('ce1' => 'customer_entity_varchar'), 'ce1.entity_id=main_table.seller_id and ce1.attribute_id = "5"', array('seller_name' => 'value'));
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
}
protected function _prepareColumns()
{
$helper = Mage::helper('sellers');
$currency = (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE);
$this->addColumn('id', array(
'header' => $helper->__('Request No'),
'index' => 'id'
));
$this->addColumn('Requested Amount', array(
'header' => $helper->__('Requested Amount'),
'index' => 'request_amount'
));
$this->addColumn('Seller Name', array(
'header' => $helper->__('Seller Name'),
'index' => 'seller_name',
));
$this->addColumn('Status', array(
'header' => $helper->__('Status'),
'index' => 'status_flag'
));
所有数据均根据 table 值正确显示。但我想显示前面带有 $
符号的 Request Amount 列值,例如300 美元等。另外,我想根据条件显示状态标志。意思是如果状态标志是 1 那么我想将值显示为 "Approved",如果标志是 2 那么 "Pending" 等等。我应该如何根据我的要求自定义收集数据并在网格中显示?帮助表示赞赏。
谢谢。
我已经回答了一个与您的要求类似的问题
How to properly add a shipping_description column in magento order grid?
检查我的答案并尝试与您的问题进行比较。在这个例子中也有我们货币问题的解决方案。
所以检查这个 out.Hope 会有帮助。
在这里你应该实现 Grid Renderer。
这是完整的教程:http://inchoo.net/magento/how-to-add-custom-renderer-for-a-custom-column-in-magento-grid/
您可以自定义任何列的值
我开发了自定义管理模块。我使用常用方法 _prepareCollection
和 _prepareColumns
在 Grid 中显示数据。
protected function _prepareCollection()
{
$collection = Mage::getModel("wallets/sellerrequest")->getCollection();
$collection->getSelect()
->join( array('ce1' => 'customer_entity_varchar'), 'ce1.entity_id=main_table.seller_id and ce1.attribute_id = "5"', array('seller_name' => 'value'));
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
}
protected function _prepareColumns()
{
$helper = Mage::helper('sellers');
$currency = (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE);
$this->addColumn('id', array(
'header' => $helper->__('Request No'),
'index' => 'id'
));
$this->addColumn('Requested Amount', array(
'header' => $helper->__('Requested Amount'),
'index' => 'request_amount'
));
$this->addColumn('Seller Name', array(
'header' => $helper->__('Seller Name'),
'index' => 'seller_name',
));
$this->addColumn('Status', array(
'header' => $helper->__('Status'),
'index' => 'status_flag'
));
所有数据均根据 table 值正确显示。但我想显示前面带有 $
符号的 Request Amount 列值,例如300 美元等。另外,我想根据条件显示状态标志。意思是如果状态标志是 1 那么我想将值显示为 "Approved",如果标志是 2 那么 "Pending" 等等。我应该如何根据我的要求自定义收集数据并在网格中显示?帮助表示赞赏。
谢谢。
我已经回答了一个与您的要求类似的问题
How to properly add a shipping_description column in magento order grid?
检查我的答案并尝试与您的问题进行比较。在这个例子中也有我们货币问题的解决方案。
所以检查这个 out.Hope 会有帮助。
在这里你应该实现 Grid Renderer。
这是完整的教程:http://inchoo.net/magento/how-to-add-custom-renderer-for-a-custom-column-in-magento-grid/
您可以自定义任何列的值