2013-06-03 23 views
1

以下代码是我的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

您可以使用过滤器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'; 
      }); 
     } 
    } 
}); 
+0

谢谢。它的效果很好 – shiro

相关问题