//新增节点
function onAddNode(e) {
var tree = mini.get("tree1");
var node = tree.getSelectedNode();
var newNode = {name: "新建分类" };
tree.addNode(newNode, "add", node);
saveData();
}
//保存节点
function saveData() {
var tree = mini.get("tree1");
var data = tree.getData();
var json = mini.encode(data);
var msgid = mini.loading("数据保存中,请稍后......", "保存数据");
jQuery.ajax({
url: "data/TreeService.jsp?method=SaveTree",
data: { data: json },
type: "post",
success: function (text) {
mini.hideMessageBox(msgid);
window.location.reload();
},
error: function (jqXHR, textStatus, errorThrown) {
alert(jqXHR.responseText);
}
});
}
public void SaveTree(HttpServletRequest request, HttpServletResponse response)throws Exception
{
String dataJSON = request.getParameter("data");
ArrayList tree = (ArrayList)Admin.dao.JSON.Decode(dataJSON);
//树形转换为列表
ArrayList list = TreeUtil.ToList(tree, "-1", "children", "id", "pid");