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

发布于 2024-10-17 22:23:17 字数 1352 浏览 2 评论 0原文

我试图在“源”列中添加选择以允许过滤,所有这些代码都运行良好,但我试图添加过滤器但没有成功,任何人都可以指出我正确的方向吗?

直到知道我有:

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'
    ));

非常感谢任何帮助 谢谢

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')
        ->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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

如果没结果 2024-10-24 22:23:17

我找到了转换的解决方案
选择选项:

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

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,
));
捂风挽笑 2024-10-24 22:23:17

类型值不应该是source。那没有任何作用。它必须是 app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/ 中的类之一。

  • 复选框
  • 国家
  • 日期
  • 日期时间
  • 屠杀
  • 价格
  • 广播
  • 范围
  • 选择
  • 商店
  • 文字
  • 主题

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文