如何删除重复的值在存储extjs



我想删除此存储中的重复值。

有时,url返回一些重复的值,我如何删除重复的值,只是列出该值1次?

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

代码,我有根据你的建议,但仍然不工作。Input1store2应该只包含唯一的值。

var input1storeArray = [];
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(store){
input1storeArray = Ext.Array.unique(store.getRange());
}
  }
});

var input1store2 = new Ext.data.SimpleStore({
field = ['name'],
data =  input1storeArray 
});

我不认为有什么内置的。您需要在模型级别强制执行它-使该字段唯一并处理错误,或者加载存储,按该字段排序并浏览所有记录,比较上一个和下一个。

最新更新