1. Define a structure zTree
var Setting = { Data: { SimpleData: { enable: to true , IDKey: " ID " , // node data stored attribute name that uniquely identifies the PIDKEY: " the parentId " , // node data stored attribute uniquely identifies the parent node name rootPId: null // root node of the above mentioned id } // json format javascript object } } // javascript object json format
2. Background returned data show page
// modify ZTree CSS style function doOpenZTree () { $ ( " #menuLayer " ) .css ( " the display " , " Block " ); // the background display data to the fetch ZTree the var URL = " MENU / doGetNodes .do " ; $ .getJSON (URL, function (Result) { IF (result.state == . 1 ) { zTree = $ .fn.zTree.init ( $ ( " #menuTree " ), Setting, result.data); } the else{ alert(result.message); } });
3. Note:
(1) Background class data returned package, the package data required Object data; variable name must be Data,
(2) 2 can be seen from the data reception have at least needed id, parentId, name these three fields
(3) needs to be encapsulated into the data entity class, namely: Data List <entity class> format