这是删除给定记录的 Ext JS 代码示例。该记录具有对其所属商店的引用。使用该存储引用与存储的删除方法相结合,您可以删除记录,如下所示。
运行下面粘贴的代码:http:
//jsfiddle.net/MSXdg/
示例代码:
Ext.define('Pies', {
extend: 'Ext.data.Model',
fields: [
'Type',
'Name'
]
})
var pieData = [{
Type:123,
Name:'apple'
}];
var store = Ext.create('Ext.data.Store',{
model:'Pies',
data: pieData,
proxy: {
type: 'memory'
}
})
var debug = Ext.fly('debug');
if (debug) {
debug.setHTML('Record count: ' + store.getCount());
}
console.log('Record count: ' + store.getCount())
var record = store.getAt(0);
// remove the record
record.store.remove(record);
// display the store count to confirm removal
if (debug) {
debug.setHTML(debug.getHTML() + '<br />Record count after removal: ' + store.getCount());
}
console.log('Record count after removal: ', store.getCount())
</p>