2013-07-20 5 views

ответ

1

Вы можете разместить прослушиватель для события 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: "[email protected]", phone: "345-2222"}, 
       { text: "Laura", leaf: true, name: "Laura", email: "[email protected]", phone: "345-3333"} 
      ] }, 
      { text: "Facebook Friend", expanded: true, children: [ 
       { text: "Steve", leaf: true, name: "Steve", email: "[email protected]", phone: "345-2222"}, 
       { text: "Lisa", leaf: true, name: "Lisa", email: "[email protected]", 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":"[email protected]", "phone":"555-222-1234" }, 
     { 'name': 'Homer', "email":"[email protected]", "phone":"555-222-1244" }, 
     { 'name': 'Marge', "email":"[email protected]", "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() 
}); 
+0

Спасибо за быстрый ответ. Я попробую этот пример. – sreekanth

+0

Работает, спасибо за помощь – sreekanth

Смежные вопросы