【发布时间】:2015-08-24 03:19:05
【问题描述】:
我尝试使用此示例并将基本 CRUD 添加到树中。
http://dev.sencha.com/deploy/ext-4.0.0/examples/tree/treegrid.html
现在,我只想从树中删除一个项目。我添加了按钮,并在点击下点击:
click : function() {;
var record = tree.getSelectionModel().getSelection()[0];
store.destroy(record);
store.sync();
}
我已验证记录和存储存在。该商店的类型为 TreeStore,如示例中所示。如果我检查正在发送的请求,它只是[]。目前我的代理中只有以下内容:
var store = Ext.create('Ext.data.TreeStore', {
storeId : 'treeStore',
model : 'Task',
proxy : {
type : 'ajax',
// the store will get the content from the .json file
url : '../resources/data/treegrid.json'
},
folderSort : true
});
单击删除不会删除当前选定的项目。我是否需要在代理中设置正确的销毁 URL,为什么它不发送任何有关需要在请求标头中删除的内容的详细信息?我找不到其他从树上执行 CRUD 的示例。
编辑:
请注意,使用store.destroy(record) 造成混淆的原因是Ext.data.Store 有一个方法remove(record) 而Ext.data.TreeStore 没有。此外,销毁的简写方法是record.destroy(),而不是record.remove(true)。
但是请注意,我在执行 record.destroy() 或 record.remove(true) 时收到了错误。大概商店需要保留节点以作为 JSON 发送,因此请改用record.remove()。
【问题讨论】: