【问题标题】:Filter admin grid with custom render values Magento使用自定义渲染值过滤管理网格 Magento
【发布时间】:2015-04-30 05:07:55
【问题描述】:

我创建了一个自定义网格,我在其中渲染了一个列 我的自定义日期。根据我返回的数据

是或否

如下图

public function render(Varien_Object $row)
            {
                $currentruleid = $this->getRequest()->getParam('id');
                $value = (int)$row->getData($this->getColumn()->getIndex());
                $read = Mage::getSingleton('core/resource')->getConnection('core_read');    
                $write = Mage::getSingleton("core/resource")->getConnection("core_write");  
                $query = "SELECT exclusive_coupon_id FROM mutually_exclusive
                WHERE rule_id ='$currentruleid' AND exclusive_coupon_id ='$value' ";  
                $result = $read->query($query);
                $affected_rows = $result->rowCount();
                if($affected_rows > 0){
                    return 'Yes';
                }
                else{
                    return 'No'; 
                    }   

            }

在网格中我的列代码是

$this->addColumn('', array(
    'header'   => Mage::helper('salesrule')->__('Exclusive'),
    'index'    => 'coupon_id',
    'width'    => '100',
    'type'     => 'options',
    'options'  => array(
        Mage::helper('adminhtml')->__('No'),
        Mage::helper('adminhtml')->__('Yes')
    ),
    'renderer' => 'adminhtml/promo_quote_edit_tab_exclusivecoupons_grid_column_renderer_used',
));

我的渲染器正在返回准确的数据

以及它在列中的显示

我还需要过滤是或否。但过滤不起作用。

你能建议我怎么做吗?

谢谢

【问题讨论】:

    标签: magento filter grid custom-controls render


    【解决方案1】:

    我已经检查过,但我的渲染器不是任何直接字段,它的自定义数据如下所示是我的渲染器函数

     public function render(Varien_Object $row)
                {
                    $currentruleid = $this->getRequest()->getParam('id');
                    $value = (int)$row->getData($this->getColumn()->getIndex());
                    $read = Mage::getSingleton('core/resource')->getConnection('core_read');    
                    $write = Mage::getSingleton("core/resource")->getConnection("core_write");  
                    $query = "SELECT exclusive_coupon_id FROM mutually_exclusive
                    WHERE rule_id ='$currentruleid' AND exclusive_coupon_id ='$value' ";  
                    $result = $read->query($query);
                    $affected_rows = $result->rowCount();
                    if($affected_rows > 0){
                        return 'Yes';
                    }
                    else{
                        return 'No'; 
                        }   
    
                }
    

    【讨论】:

    • 如果您使用“$this->getCollection()->getData()”(在“filter_condition_callback”函数内部)获取数据并根据所选值自行管理数组然后重置集合怎么办数据。
    • 使用前面提供的链接为您的 addColumn 代码定义“filter_condition_callback”函数,然后在该函数内部获取集合数据,根据过滤器值处理数组并使用处理后的数组设置集合。
    猜你喜欢
    • 1970-01-01
    • 2015-06-15
    • 1970-01-01
    • 2023-03-14
    • 1970-01-01
    • 2015-03-08
    • 1970-01-01
    • 1970-01-01
    • 2015-09-10
    相关资源
    最近更新 更多