Grid Extjs4如何从网格中删除重复的行?
Grid Extjs4如何从网格中删除重复的行?,grid,extjs4,filtering,Grid,Extjs4,Filtering,我的网格包含许多重复的行(相同的名称和用户名,具有不同的隐藏id)。如何删除重复的行?您应该设置代理读取器或模型的idProperty var myStore = Ext.create('Ext.data.Store', { proxy: { type: 'ajax', url: '/myUrl', reader: { idProperty: 'Id' } }, model: 'myM
我的网格
包含许多重复的行(相同的名称
和用户名
,具有不同的隐藏id
)。如何删除重复的行?您应该设置代理读取器或模型的idProperty
var myStore = Ext.create('Ext.data.Store', {
proxy: {
type: 'ajax',
url: '/myUrl',
reader: {
idProperty: 'Id'
}
},
model: 'myModel'
});
您应该设置代理读取器或模型的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);
这段代码非常适合您: 重要的是,您要用这个声明您的存储和网格。 例如
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);
这会有所帮助,但当我设置存储的idProperty时,网格将显示为filtered,但我希望在单击按钮时对其进行筛选并删除重复的行!那么,我可以更改商店idProperty的值吗?我尝试了
Ext.getCmp('My_grid').getStore().set(idProperty,'Id')
,但那是错误的!它没有set
方法,而且idProperty
是读卡器/模型的配置。你应该喜欢上面的例子。我可以做一个组合属性吗?我的意思是在同一个idProperty中有两个值这很有帮助,但当我设置存储的idProperty时,网格将显示为已过滤,但我想在单击按钮时对其进行过滤并删除重复的行!那么,我可以更改商店idProperty的值吗?我尝试了Ext.getCmp('My_grid').getStore().set(idProperty,'Id')
,但那是错误的!它没有set
方法,而且idProperty
是读卡器/模型的配置。你应该喜欢上面的例子。我可以做一个组合属性吗?我指的是同一idProperty中的两个值