在网格菜单中添加列选择过滤器

在网格菜单中添加列选择过滤器

问题描述:

我想添加选择在我的列“来源”,以允许过滤器,所有这些代码工作正常,但我试图添加没有任何成功的过滤器,任何人都可以指向我正确的方向?在网格菜单中添加列选择过滤器

直到知道我有:

protected function _prepareCollection() 
{ 
    $collection = Mage::getResourceModel('customer/customer_collection') 
     ->addNameToSelect() 
     ->addAttributeToSelect('email') 
     ->addAttributeToSelect('created_at') 
     ->addAttributeToSelect('group_id') 
     ->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left') 
     ->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left') 
     ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left') 
     ->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left') 
     ->joinAttribute('source', 'customer/source', 'default_billing', null, 'left') 
     ->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left'); 

    $this->setCollection($collection); 

    return parent::_prepareCollection(); 
} 

$this->addColumn('source', array(
     'header' => Mage::helper('customer')->__('Source'), 
     'type'  => 'source', 
     'index'  => 'source' 
    )); 

任何帮助将非常apreciated 感谢

我找到了解决方案,用于 变换选择选项:

$sql = 'SELECT distinct value FROM `....'; 
$data = Mage::getSingleton('core/resource') ->getConnection('core_read')->fetchAll($sql); 

$soTypes=array(); 
foreach($data as $array){ 
    foreach($array as $key => $value){ 
    if(!empty($value)){ 
     $so[$value]=$value; 
    } 
    } 
} 

$this->addColumn('invoice_so', array(
    'header' => Mage::helper('sales')->__('SoTypes'), 
    'index'  => 'value', 
    'width'  => '100px', 
    'type'  => 'options', 
    'options' => $soTypes, 
)); 

类型值不应source。那什么都不做。它需要是app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/中的一个类。

  • 复选框
  • 国家
  • 日期
  • 日期时间
  • Massaction
  • 价格
  • 无线电
  • 范围
  • 选择
  • 商店
  • 文本
  • 主题