我开发了自定义管理模块。我使用了常用的方法_ 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'
));
根据表值正确显示所有数据。但我想在$
符号之前显示请求金额列值,例如$ 300等。另外,我想根据条件显示状态标志。意味着如果状态标志为1,那么我想将值显示为“已批准”,如果标志为2则为“待定”等。我应该如何自定义收集数据并根据我的要求在网格中显示?帮助赞赏。
感谢。
答案 0 :(得分:1)
我已经回答了类似于您的要求的问题
How to properly add a shipping_description column in magento order grid?
检查我的回答并尝试与您的问题进行比较。在这个例子中,我们也有解决货币问题的方法。
所以请检查一下。希望它会有所帮助。
答案 1 :(得分:1)
在这里你应该实现Grid Renderer。
以下是完整的教程:http://inchoo.net/magento/how-to-add-custom-renderer-for-a-custom-column-in-magento-grid/
您可以自定义任何列的值