My_grid
包含许多重复的行(相同的name
和username
,并且具有不同的隐藏的id
)。如何删除重复的行?
您应该在代理的阅读器上或在模型上设置idProperty。
var myStore = Ext.create('Ext.data.Store', {
proxy: {
type: 'ajax',
url: '/myUrl',
reader: {
idProperty: 'Id'
}
},
model: 'myModel'
});
此片段希望对您有用:
重要的是,您要以此声明商店和网格。例如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);