如何排除extjs商店中的特定值

时间:2013-06-03 17:05:46

标签: javascript extjs

以下代码是我的extjs商店。我想从这家商店中排除一些特定的价值。

例如,“选项1”,“选项2”等值将从商店中排除,或者当我检索此商店并显示在输入下拉字段中时。

我该怎么做?

谢谢。

 var input1store = new Ext.data.Store({
fields: [{name: 'name'}],
proxy:{
    type: 'ajax',
    url:    'www.requesturl.com?format=json&source1',
            reader: {
        type: 'json',
        root:   'xml.result'
    }
},
autoLoad:false,
sorters:    [{property: 'name', direction: 'asc'}]
});

1 个答案:

答案 0 :(得分:1)

您可以使用过滤器http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.Store-method-filter

var input1store = new Ext.data.Store({
    fields: [{name: 'name'}],
    proxy:{
        type: 'ajax',
        url:    'www.requesturl.com?format=json&source1',
        reader: {
            type: 'json',
            root:   'xml.result'
        }
    },
    autoLoad:false,
    sorters:    [{property: 'name', direction: 'asc'}],

    listeners: { 
       load: function() {
           this.filter(function(rec){
               var val = rec.get('name');
               return val != 'option1' && val != 'option2';
           });
       }
    }
});
相关问题