Sencha treepanel에서 선택된 row 정보 가져오기
2024. 12. 5. 16:28ㆍJavascript/Sencha
treepanel에서 정보를 가져옴
// Assuming 'treePanel' is the reference to your TreePanel instance
var selectedNodes = treePanel.getSelectionModel().getSelection();
// Iterate through the selected nodes
selectedNodes.forEach(function(node) {
console.log('Selected Node:', node.get('text')); // Replace 'text' with the field name you want
});
Ext.create('Ext.tree.Panel', {
title: 'Sample TreePanel',
width: 400,
height: 300,
renderTo: Ext.getBody(),
rootVisible: false,
store: {
root: {
expanded: true,
children: [
{ text: 'Node 1', leaf: true },
{ text: 'Node 2', leaf: true },
{ text: 'Folder', expanded: true, children: [
{ text: 'SubNode 1', leaf: true },
{ text: 'SubNode 2', leaf: true }
]}
]
}
},
listeners: {
itemclick: function (view, record) {
console.log('Selected Node:', record.get('text'));
},
selectionchange: function (model, selected) {
selected.forEach(function (node) {
console.log('Selected during selection change:', node.get('text'));
});
}
}
});
store에서 정보를 가져옴
var treePanel = Ext.ComponentQuery.query('treepanel')[0]; // Get the TreePanel
var store = treePanel.getStore(); // Get the TreePanel's store
// Function to check and collect selected nodes
var selectedNodes = [];
store.each(function(record) {
if (record.get('checked')) { // Check for a specific selection state (like checkbox selection)
selectedNodes.push(record);
}
});
// Log the selected nodes
selectedNodes.forEach(function(node) {
console.log('Selected Node:', node.get('text')); // Replace 'text' with the desired field
});
'Javascript > Sencha' 카테고리의 다른 글
Sencha treepanel의 모든 node 펼치기 (0) | 2024.12.05 |
---|---|
Sencha Object 접근하기 (0) | 2024.12.05 |
Sencha Grid의 체크박스 사용하기 (0) | 2024.12.05 |
Sencha TreePanel 사용시 주의사항 (0) | 2024.12.01 |
Sencha Uncaught Error: [Ext.create] (0) | 2024.12.01 |