双击树面板应该添加到网格面板Extjs中
Double click in treepanel should add in grid panel Extjs
我是extjs的新手,有人能帮我吗。
当我双击树面板中的一个项目时,它应该添加到网格面板中,而不会对树面板进行任何更改。
您可以在树面板上放置'itemdblclick'事件的侦听器,以从双击的项的原始属性中获取数据。然后,通过引用底层网格的存储,只需使用存储的"loadRawData"方法附加该数据对象。以下是基于Sencha网站示例的代码示例:
var store = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
children: [
{ text: "School Friends", expanded: true, children: [
{ text: "Mike", leaf: true, name: "Mike", email: "mike@stackoverflow.com", phone: "345-2222"},
{ text: "Laura", leaf: true, name: "Laura", email: "laura@stackoverflow.com", phone: "345-3333"}
] },
{ text: "Facebook Friend", expanded: true, children: [
{ text: "Steve", leaf: true, name: "Steve", email: "steve@stackoverflow.com", phone: "345-2222"},
{ text: "Lisa", leaf: true, name: "Lisa", email: "lisa@stackoverflow.com", phone: "345-3333"}
] },
]
}
});
Ext.create('Ext.tree.Panel', {
title: 'All My Friends',
width: 200,
height: 150,
store: store,
rootVisible: false,
renderTo: Ext.getBody(),
listeners : {
itemdblclick : function(tree, record, index){
Ext.getStore('simpsonsStore').loadRawData([record.raw], true);
}
}
});
Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['name', 'email', 'phone'],
data:{'items':[
{ 'name': 'Bart', "email":"bart@simpsons.com", "phone":"555-222-1234" },
{ 'name': 'Homer', "email":"home@simpsons.com", "phone":"555-222-1244" },
{ 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254" }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});
Ext.create('Ext.grid.Panel', {
title: 'Best Friends',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ text: 'Name', dataIndex: 'name' },
{ text: 'Email', dataIndex: 'email', flex: 1 },
{ text: 'Phone', dataIndex: 'phone' }
],
height: 200,
width: 400,
renderTo: Ext.getBody()
});
相关文章:
- ExtJS网格单元格编辑器,防止焦点松动问题
- EXTJS 5树状网格自定义行css
- 如何使ExtJS网格面板成为真正的只读组件
- Extjs 4网格:根据存储文本值在单元格中放置图标
- ExtJS使网格高度达到100%
- ExtJS网格在存储更新后未刷新
- 如何在ExtJS网格上创建带有标签的文本字段
- ExtJS网格未从Ext.data.XmlStore加载数据
- 当在EXTJS中的网格中使用时,afterrender不适用于组合框
- 由于本地存储代理,Extjs网格面板最多显示25行.如何更改此限制值
- 禁用鼠标单击网格,当 ext.window 打开 extjs 3
- 在 EXTJS 中启用多选网格时面临问题
- 在 ExtJS 中更新选项卡开关上的网格面板
- extJs 5 - 网格多级分组
- Extjs 3.4 中属性网格行值的工具提示 /Qtip(鼠标悬停)
- 在网格extjs中添加行
- 当鼠标悬停在网格extjs上的行的行体上时,检索行值
- 使用选择框对网格Extjs进行分组
- 更改groupField并重新加载网格Extjs 4
- 从网格ExtJs 4中获取一行