Magento 使用自定义渲染值筛选管理网格
我已经创建了一个自定义网格,其中有一列是我渲染的 我的自定义日期。根据我返回的数据 是还是不是 如下Magento 使用自定义渲染值筛选管理网格,magento,filter,grid,custom-controls,render,Magento,Filter,Grid,Custom Controls,Render,我已经创建了一个自定义网格,其中有一列是我渲染的 我的自定义日期。根据我返回的数据 是还是不是 如下 public function render(Varien_Object $row) { $currentruleid = $this->getRequest()->getParam('id'); $value = (int)$row->getData($this->getColumn
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',
));
我的渲染器正在返回准确的数据
并以栏目形式展示
我还需要使用“是”或“否”进行筛选。但筛选不起作用
你能告诉我怎么做吗
谢谢
我已经检查过了,但我的渲染器不是任何直接字段,它是一个自定义数据,如下所示是我的渲染器函数
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\u condition\u callback”函数中)获取数据并根据所选值自行管理数组,然后重置收集数据,该怎么办?定义“filter\u condition\u callback”函数使用前面提供的链接添加列代码,然后在该函数内部获取集合数据,根据筛选器值处理数组,并使用已处理的数组将集合设置回原位。