MiM*_*iMo 6 magento magento-1.7
我在管理网格中的模块中有过滤器问题.
我的问题是:过滤自定义渲染器不起作用的列.
public function _prepareColumns()
{
$this->addColumn('entity_id', array(
'header' => 'ID',
'index' => 'entity_id',
'width' => '30px'
));
$this->addColumn('author', array(
'header' => 'Author',
'index' => 'author',
'renderer' => 'Test_Block_Adminhtml_Vj_Renderer_Author'
));
Run Code Online (Sandbox Code Playgroud)
渲染器是
class Test_Block_Adminhtml_Vj_Renderer_Author extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
public function render(Varien_Object $row)
{
$value = $row->getData($this->getColumn()->getIndex());
$autor = Mage::getModel('test/test')->load($value);
return ($author->getName() . ' ' . $author->getSurname());
}
}
Run Code Online (Sandbox Code Playgroud)
网格中的作者显示例如'乔治布什',但如果我尝试写过滤(例如'Bu')过滤器返回零行.: - /
任何的想法?谢谢.
Scr*_*aws 15
这篇文章可能会有所帮助...... http://www.atwix.com/magento/grid-filter-for-columns/
在对自定义字段的addColumn()调用中,添加类似于...的内容
'filter_condition_callback' => array($this, '_myCustomFilter'),
然后添加过滤方法(根据需要更改"where()")...
protected function _myCustomFilter($collection, $column)
{
if (!$value = $column->getFilter()->getValue()) {
return $this;
}
$this->getCollection()->getSelect()->where(
"my_field like ?"
, "%$value%");
return $this;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14049 次 |
| 最近记录: |