【问题标题】:magento show content according to condition in admin gridmagento 根据管理网格中的条件显示内容
【发布时间】:2015-01-02 19:11:48
【问题描述】:

我开发了自定义管理模块。我使用了常用的方法 _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,则“待定”等。我应该如何自定义收集数据并根据我的要求在网格中显示?帮助表示赞赏。

谢谢。

【问题讨论】:

    标签: magento


    【解决方案1】:

    我已经回答了一个与您的要求类似的问题

    How to properly add a shipping_description column in magento order grid?

    检查我的答案并尝试与您的问题进行比较。在这个例子中,我们的货币问题也有解决方案。

    所以看看这个。希望它会有所帮助。

    【讨论】:

      【解决方案2】:

      这里你应该实现网格渲染器。

      这是完整的教程:http://inchoo.net/magento/how-to-add-custom-renderer-for-a-custom-column-in-magento-grid/

      您可以自定义任何列的值

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-01-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多