JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://www.jeasyui.com/easyui/themes/default/easyui.css">
<script src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
<input id="cc">
JavaScript
var data = [{
"id":1,
"text":"My Documents",
"children":[{
"id":11,
"text":"Photos",
"state":"closed",
"children":[{
"id":111,
"text":"Friend"
},{
"id":112,
"text":"Wife"
},{
"id":113,
"text":"Company"
}]
},{
"id":12,
"text":"Program Files",
"children":[{
"id":121,
"text":"Intel"
},{
"id":122,
"text":"Java",
"attributes":{
"p1":"Custom Attribute1",
"p2":"Custom Attribute2"
}
},{
"id":123,
"text":"Microsoft Office"
},{
"id":124,
"text":"Games",
"checked":true
}]
},{
"id":13,
"text":"index.html"
},{
"id":14,
"text":"about.html"
},{
"id":15,
"text":"welcome.html"
}]
}]
function myLoadFilter(data, parent){
var state = $.data(this, 'tree');
function setData(){
var serno = 1;
var todo = [];
for(var i=0; i<data.length; i++){
todo.push(data[i]);
}
while(todo.length){
var node = todo.shift();
if (node.id == undefined){
node.id = '_node_' + (serno++);
}
if (node.children){
node.state = 'closed';
node.children1 = node.children;
node.children = undefined;
todo = todo.concat(node.children1);
}
}
state.tdata = data;
}
function find(id){
var data = state.tdata;
var cc = [data];
while(cc.length){
var c = cc.shift();
for(var i=0; i<c.length; i++){
var node = c[i];
if (node.id == id){
return node;
} else if (node.children1){
cc.push(node.children1);
}
}
}
return null;
}
setData();
var t = $(this);
var opts = t.tree('options');
opts.onBeforeExpand = function(node){
var n = find(node.id);
if (n.children && n.children.length){return}
if...