如何在TreePanel中插入新记录(模型)?
我使用 TreeStore
& 树面板
。我需要在我的 Tree 中插入新节点,该怎么做?
我有 TreeStore
组件,它遵循配置:
var monPrestore = Ext.create('Ext.data.TreeStore', {
folderSort : true,
model : 'Task',
proxy : {
model : 'Task',
appendId: true,
type : 'ajax',
url : '/intranet-timesheet2-tasks-extjs/getJSON.tcl',
reader : {
type : 'json'
},
writer : {
type : 'json'
},
}
我已经定义了带有空白值的任务模型(这是我想要插入的内容):
Ext.define('Task', {
extend : 'Ext.data.Model',
fields : [
{
name : 'task',
type: 'string'
},
{
name : 'material',
type: 'string'
},
{
name : 'cc',
type: 'string'
},
{
name : 'start_date',
type: 'string'
},
{
name : 'short_desc',
type: 'string'
},
{
name : 'id',
type: 'string'
}
]
});
我想在事件 itemdlclick
发生时插入新记录解雇:
我已经测试过,但它不起作用:
itemdblclick: function(view, model, htmlitem, index, e) {
var task = {
task: 't0',
material: 'm0',
cc: 'c0',
start_date: '12',
short_desc: 'sht',
id: '120',
leaf: true
};
monPretree.insert(4,task);
}
非常感谢:)!
I use TreeStore
& TreePanel
. I need to insert new node in my Tree , how to this?
I have TreeStore
component who following config:
var monPrestore = Ext.create('Ext.data.TreeStore', {
folderSort : true,
model : 'Task',
proxy : {
model : 'Task',
appendId: true,
type : 'ajax',
url : '/intranet-timesheet2-tasks-extjs/getJSON.tcl',
reader : {
type : 'json'
},
writer : {
type : 'json'
},
}
I have defined Task Model (it is what I want to insert) with blank value:
Ext.define('Task', {
extend : 'Ext.data.Model',
fields : [
{
name : 'task',
type: 'string'
},
{
name : 'material',
type: 'string'
},
{
name : 'cc',
type: 'string'
},
{
name : 'start_date',
type: 'string'
},
{
name : 'short_desc',
type: 'string'
},
{
name : 'id',
type: 'string'
}
]
});
I want to insert new record when event itemdlclick
is fired:
I have tested that but it doesn't work:
itemdblclick: function(view, model, htmlitem, index, e) {
var task = {
task: 't0',
material: 'm0',
cc: 'c0',
start_date: '12',
short_desc: 'sht',
id: '120',
leaf: true
};
monPretree.insert(4,task);
}
Thanks a lot :) !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您在此处提出了类似的问题!
树面板没有插入方法。您必须掌握树的根节点才能修改树。在您的情况下,您可能必须执行以下操作:
对于其他树操作方法,请参阅 NodeInterface。
I think you asked the similar question here!
There is no insert method for tree panel. You will have to get hold of the tree's root node to modify the tree. In your case, you might have to do the following:
For other tree manipulation methods, refer the API documentation of NodeInterface.