开发者

add column SELECT filter in grid menu

I’m trying to add select in my column “Sources” to allow filter, all this code works well, but I’m trying to add filter without any success, anyone can point me in the right direction?

Until know I have:

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')
   开发者_StackOverflow中文版     ->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left');

    $this->setCollection($collection);

    return parent::_prepareCollection();
}

and

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

Any help will be very apreciated thanks


I found the solution for transform in a Select option:

$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,
));


The type value should not be source. That doesn't do anything. It needs to be one of the classes in app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/.

  • Checkbox
  • Country
  • Date
  • Datetime
  • Massaction
  • Price
  • Radio
  • Range
  • Select
  • Store
  • Text
  • Theme
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜