magento grid filter

piaoling  2012-03-05 15:40:34

in the grid block file,add function

protected function _addColumnFilterToCollection($column)
    {
        // Set custom filter for in category flag
        if ($column->getId() == 'vip_no') {
            $filter = $column->getFilter();
            $filterValue = $filter->getValue();
            
            $cond = $column->getFilter()->getCondition();
            
            $field = ( $column->getFilterIndex() ) ? $column->getFilterIndex() : $column->getIndex();
            //$this->getCollection()->addFieldToFilter($field, $cond);

            $this->getCollection()->getSelect()->where($field."='".$filterValue."'");
            var_dump((string)$this->getCollection()->getSelect());
        }
        else {
            parent::_addColumnFilterToCollection($column);
        }
        return $this;
    }

this can be rewrite the default grid filter.

类别 :  magento(258)  |  浏览(3902)  |  评论(0)
发表评论(评论将通过邮件发给作者):

Email: