My_grid
contains many duplicated rows (same name
and username
, and with different hidden id
). How to remove duplicated rows?
问问题
1915 次
2 回答
3
您应该设置代理阅读器或模型上的idProperty。
var myStore = Ext.create('Ext.data.Store', {
proxy: {
type: 'ajax',
url: '/myUrl',
reader: {
idProperty: 'Id'
}
},
model: 'myModel'
});
于 2013-02-26T12:56:04.520 回答
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);
于 2013-03-02T20:14:02.567 回答