如何删除商店中的重复值extjs
问题描述:
我想删除此商店中的重复值。如何删除商店中的重复值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
});
答
我不认为有什么内置的。您需要在模型级别强制执行此操作 - 使此字段具有唯一性并处理错误,或者加载商店,按该字段进行排序并浏览比较上一个和下一个的所有记录。
我试图根据你在这里的建议来做。但我未能使其工作。这有可能是你给我一个例子或一个快速的代码。 THanks – shiro
你可以发布你的代码,我会尽力帮你找到一个错误? – sha
我已经更新了上面的问题,包括代码来收集独特的价值,但它似乎并没有工作。 – shiro