JSFiddle - React, Tailwind, and code Playground

by ric47121

HTML

<link rel="stylesheet" href="http://dev.sencha.com/deploy/ext-4.0.2a/resources/css/ext-all.css">
<input type="button" onclick="elegir()" value="tocame">

JavaScript

var store = Ext.create('Ext.data.TreeStore', {
    root: {
        expanded: true,
        children: [
            { text: "detention", id:'item_1', leaf: true },
            { text: "homework", id:'item_2', expanded: true, children: [
                { text: "book report", id:'item_3', leaf: true },
                { text: "alegrbra", id:'item_4', leaf: true}
            ] },
            { text: "buy lottery tickets", id:'item_5', leaf: true }
        ]
    }
});

Ext.create('Ext.tree.Panel', {
    title: 'Simple Tree',
    id:'tree-panel',
    width: 200,
    height: 200,
    store: store,
    autoScroll: true,
    //rootVisible: false,
    renderTo: Ext.getBody()
});

var tree = Ext.getCmp('tree-panel');
tree.getSelectionModel().select(3);

//console.log(Ext.getCmp('item_3'))

function elegir(){
    var TreeNodeId = 'item_1'; //the id of the tree node which is being clicked
    var treepanel = Ext.getCmp('tree-panel');
    treepanel.expandAll();
    
    var record = treepanel.getRootNode().findChild("id",TreeNodeId, true);
    console.info(record)
    treepanel.getSelectionModel().select(record);
}