Sencha treepanel row 선택하기

2024. 12. 5. 18:05Javascript/Sencha

Row ID로 선택하기

// Assuming your TreePanel is already created and has an id or reference
Ext.onReady(function () {
    var treePanel = Ext.getCmp('myTreePanel'); // Replace 'myTreePanel' with your TreePanel's id

    // Get the selection model
    var selectionModel = treePanel.getSelectionModel();

    // Find a node by id or some other identifier
    var node = treePanel.getStore().getNodeById('desiredNodeId'); // Replace 'desiredNodeId' with the actual node id

    if (node) {
        // Select the node
        selectionModel.select(node);
    } else {
        console.error('Node not found!');
    }
});

 Root Node 선택하기

Ext.onReady(function () {
    // Assuming your TreePanel is already created and has an id or reference
    var treePanel = Ext.getCmp('myTreePanel'); // Replace 'myTreePanel' with your TreePanel's id

    // Get the root node from the TreeStore
    var rootNode = treePanel.getStore().getRootNode();

    if (rootNode) {
        // Select the root node using the TreePanel's selection model
        treePanel.getSelectionModel().select(rootNode);
    } else {
        console.error('Root node not found!');
    }
});