Netzke网格过滤

时间:2013-07-19 05:52:56

标签: netzke

我遇到了与在Netzke Grid中过滤数据相关的问题。

    column :user_id do |c|
      c.editor = {xtype: :combobox, editable: false, min_chars: 2}
    end

在文件中提到, 将覆盖自动编辑器配置的哈希。例如,对于一对多关联列,您可以将其设置为{min_chars:1},它将被传递到组合框并使其在输入1个字符(而不是默认值4)后查询其远程数据。

似乎{min_chars: 1}未按预期工作。

1 个答案:

答案 0 :(得分:1)

请参阅下面的示例,了解简单的客户网格,并告诉我它是否适合您。 Netzke的方法是使用__(双下划线)来定义一对多关联。这为您提供了组合框和所有必要的数据绑定。我尝试了不同的方法使min_chars属性工作,但都失败了。可能是一个错误。最后,唯一有效的方法是从init_component方法开始。

class Customers < Netzke::Basepack::Grid
  def configure(c)
    super
    c.model = 'Customer'
    c.columns = [
      { name: :name, header: 'Customer Name' },
      { id: :country__name, name: :country__name, header: 'Country' }
    ]
  end

  js_configure do |c|
    c.init_component = <<-JS
      function() {
        this.callParent();
        Ext.ComponentManager.get('country__name').editor.minChars = 2;
      }
    JS
  end

end