在网格编辑组合框的ExtJS的滤波

问题描述 投票:1回答:2

我有一个组合框编辑网格。我想根据该行的记录中的值来筛选组合框店。

我现在有这样的:

editor: {
    xtype: 'combo',
    forceSelection: true,
    store: 'ship.Transportmodes',
    displayField: 'name',
    valueField: 'id',
    queryMode: 'local',
    listeners: {
        expand: function(combo){
            var shipper = combo.up('grid').editingPlugin.activeRecord.get('shipper');
            combo.store.filterBy(function(record){
                console.log(record.get('shippers').indexOf(shipper))
                return record.get('shippers').indexOf(shipper) != -1
            })
        }
    },
    editable: false
}},

这是工作,但有一个问题:当下拉列表是否显示在该领域的顶端,其余选项远从外地出现,被去除的选择的空间还是分配。 screenshot

我试图筛选存储在任何这些事件:

  • 格:beforeedit
  • 组合:beforerender
  • 组合:渲染
  • 组合:一个AfterRender

在每一种情况下,结果如下:这家商店被正确地过滤,但在组合框中展开时,过滤器被清除。

我想知道发生了什么。为什么一个组合框始终显示的选项列表之前清除其商店的过滤器?

任何人都可以给幕后的见解?或者告诉我什么,我缺少了吗?

extjs filter combobox extjs4.2
2个回答
4
投票

你可以这样做: 小提琴链接:https://fiddle.sencha.com/#fiddle/1hle

Ext.application({
    name : 'Fiddle',

    simpsonsStore : Ext.create('Ext.data.Store', {
        storeId : 'simpsonsStore',
        fields : ['name', 'email'],
        data : [
            {name : 'Lisa',email : '[email protected]',id:1}, 
            {name : 'Bart', email : '[email protected]',id:2}, 
            {name : 'Homer', email : '[email protected]',id:3},
            {name : 'Marge',email : '[email protected]',id:4}]
    }),

    tagfieldstore : Ext.create('Ext.data.Store', {
        fields : ['tag', 'field'],
        data : [
            {aid:1,tag : 'tag1',field : 'lisa record1'}, 
            {aid:1,tag : 'tag3',field : 'lisa record2'}, 
            {aid:3,tag : 'tag1',field : 'homer record3'}, 
            {aid:3,tag : 'tag3',field : 'homer record4'},
            {aid:2,tag : 'tag1',field : 'bart record1'}, 
            {aid:2,tag : 'tag3',field : 'bart record2'}, 
            {aid:4,tag : 'tag1',field : 'marge record3'}, 
            {aid:4,tag : 'tag3',field : 'marge record4'}]
    }),

    launch : function() {

        Ext.create('Ext.grid.Panel', {
            title : 'Simpsons',
            store : this.simpsonsStore,
            columns : [{
                flex :1 ,
                text : 'Name',
                dataIndex : 'name',
            }, {
                text : 'Email',
                dataIndex : 'email',
                flex : 1
            }, {
                xtype : 'widgetcolumn',
                cellWrap : true,
                text : 'Phone',
                flex : 1,
                widget : {
                    xtype: 'combo',
                    store : this.tagfieldstore,
                    valueField : 'tag',
                    displayField : 'field',
                    growMax : true, 
                    listeners:{
                       expand:function(combo){
                           combo.store.clearFilter();
                          var id = combo.$widgetRecord.data.id;
                           combo.store.filterBy(function(rec){
                                return rec.data.aid == id;
                          });
                       }
                    }

                }
            }],
            flex : 1,
            renderTo : Ext.getBody()
        });
    }
});

2
投票

最后我想通了。问题不ExtJS已经是一个组合框”店清除过滤器。问题就来了,从过滤器的工作的missunderstanding。事实上filterBy过滤店只是暂时的,但不保存该过滤器在店里。

在另一方面,addFilter({filterFn: ...})添加过滤器到商店的filters集合。

那些与addFilter商店添加过滤器仍然会渲染组合框后应用,这与filterFn应用的滤镜是挥发性。

现在,我可以添加网格qazxsw POI事件的过滤器,并删除它qazxsw POI和qazxsw POI。

喜爱

我有一个组合框编辑网格。我想根据该行的记录中的值来筛选组合框店。

我现在有这样的:

beforeedit

控制器:

edit
© www.soinside.com 2019 - 2024. All rights reserved.