//深拷贝
//var voList = util.getCache('voList')
var voList = []
for (var i = 0, l = data.lengthi <li++) {
var el = data[i]
var obj = new WifiVO({
stime: el.stime,
macadd: el.macadd,
vendor: el.vendor,
VlanID: el.VlanID,
protocolName: el.protocolName,
sessionTime: el.sessionTime,
Avg: el.Avg,
Bytesent: el.Bytesent,
ByteReceived: el.ByteReceived,
RSSI: el.RSSI,
building: el.building,
room: el.room
})
//console.log(obj)
voList.push(obj)
}
return voList
}
function initApp(){
initDataTree()
}
function initDataTree(callback) {
//传入数据
$.getJSON('data/test.json', function(data) {
//console.log(data)
buildVOList(data)
callback &&callback()
})
}
links 是节点数组中的索引,应该从0开始。从1开始,因此最高的数字' t存在,并给你这个错误。
使用easyui 需要页面引用必须的js和css<link href="../../../Easyui/themes/default/easyui.css" rel="stylesheet" type="text/css"/>
<link href="../../../Easyui/themes/icon.css" rel="stylesheet" type="text/css" />
<script src="../../../Easyui/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="../../../Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="../../../Easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
// easyui tree 一般只需要url一个属性即可显示数据,tree会自动ajax加载数据
// 至于点击树节点如何显示相应页面 ,tree 的json数据格式里面有attributes 可以自定义url
//就像下面例子中的 \"attributes\":{\"jsUrl\"……,下面的列子 是我在js里面拼接的tree json数据
/*********************************************************************************/
/*初始化树*/
InitTree: function () {
/*初始化树*/
$('#tree').tree({
animate: true,
//lines: true,
checkbox: false,
data: TableToXml.TreeData(),
onContextMenu: function (e, node) {
e.preventDefault() //阻止浏览器默认右键菜单
// select the node
if (node.id != -1 && node.id != -2 && node.id != -3) {
$('#txt_xml').attr('disabled', 'true')
$('#btn_save').linkbutton('disable')
TableToXml.currtableName = node.id
TableToXml.currJsUrl = node.attributes.jsUrl
$('#mm').menu('show', {
left: e.pageX,
top: e.pageY
})
}
}
})
},
//组合树json数据
TreeData: function () {
var TreeJson = '[{\"id\":-1,\"text\":\"Tables\",\"children\":['
TreeJson += '{\"id\":-2,\"text\":\"废水污染源核算\",\"children\":['
for (var j = 0 j < TableToXml.tableArray[0].length j++) {
TreeJson += '{\"id\":\"' + TableToXml.tableArray[0][j].split('$')[0] + '\",\"text\":\"' + TableToXml.tableArray[0][j].split('$')[1] + '\",\"attributes\":{\"jsUrl\":\"' + TableToXml.tableArray[0][j].split('$')[2] + '\"}}'
if (j < TableToXml.tableArray[0].length - 1)
TreeJson += ','
}
TreeJson += ']},'
TreeJson += '{\"id\":-3,\"text\":\"废气污染源核算\",\"state\": \"closed\",\"children\":['
for (var j = 0 j < TableToXml.tableArray[1].length j++) {
TreeJson += '{\"id\":\"' + TableToXml.tableArray[1][j].split('$')[0] + '\",\"text\":\"' + TableToXml.tableArray[1][j].split('$')[1] + '\",\"attributes\":{\"jsUrl\":\"' + TableToXml.tableArray[1][j].split('$')[2] + '\"}}'
if (j < TableToXml.tableArray[1].length - 1)
TreeJson += ','
}
TreeJson += ']}]}]'
TreeJson = eval("(" + TreeJson + ")")
return TreeJson
},
另附API里tree
$('#tt').tree({
url: ...,//tree会自动ajax后台获取json格式数据(需要自己后台拼接)
loadFilter: function(data){
if (data.d){
return data.d
} else {
return data
}
}
})
多看看api吧……