My_grid
包含许多重复的行(相同的name
和username
,以及不同的隐藏id
)。如何删除重复的行?
答案 0 :(得分:3)
您应该设置代理阅读器或模型的 idProperty 。
var myStore = Ext.create('Ext.data.Store', {
proxy: {
type: 'ajax',
url: '/myUrl',
reader: {
idProperty: 'Id'
}
},
model: 'myModel'
});
答案 1 :(得分:1)
这段代码希望对您有用:
使用此方法声明商店和网格非常重要。例如“this.store = ...”
//Listener on the button removes the duplicated rows
this.button.on('click', function(){
this.store.each(function(record){
//This is necessary because if this record was removed before
if(record !== undefined){
//Find all records which have the same name like this record
var records = record.store.query('name', record.get('name'));
//Remove all found records expect the first record
records = records.each(function(item, index){
//Don't delete the first record
if(index != 0){
item.store.remove(item);
}
});
}
});
}, this);