tree 查询出数据遍历tree

$('#tree1').tree({
url:'${contextPath}/pedition/treelistJc.html?editionUid=${ formatEdition.ppmId}',
onAfterEdit:function(node){
var count = 0;
for(var i = 0 ; i < node.text.length ; i++) {
if ((node.text.charCodeAt(i)>=0) && (node.text.charCodeAt(i)<=255)) {
count=count+1;
}else {
count=count+3;
}
}
if(count<1 || count>150){
var message = "";

if(node.text.length<1) {
message = "ÇëÊäÈëÕ½ÚÃû³Æ";
}
if(count>150) {
message = "Õ½ÚÃû³Æ²»Äܳ¬¹ý150¸öÓ¢ÎÄ»ò50¸öÖÐÎÄ×Ö";
}

$.messager.alert("Ìáʾ",message,"info");
$('#tree1').tree('beginEdit', node.target);
return ;
}
var reg = /^[a-zA-Z0-9._@\u4E00-\u9FA5]+$/;
if(!reg.test(node.text)) {
$.messager.alert("Ìáʾ","Ö»ÔÊÐíÊäÈ뺺×Ö¡¢Ó¢ÎÄ×Öĸ¡¢Êý×Ö¼°Ï»®Ïߣ¬µã£¬@","info");
node.text = "н¨Õ½Ú";
$('#tree1').tree('beginEdit', node.target);
return ;
}
$('#laHide').hide();
$('.easyui-linkbutton').linkbutton('enable');
$('.easyui-menubutton').menubutton('enable');
//alert("Íê³É±à¼­"+node.text+"--"+nodexu.text);
if((nodexu == null || nodexu==""|| (nodexu!=""&&nodexu.id!=node.id)) && buttonflag!="edit_section"){
var parentid="null";
if(nodexu!="" && nodexu!=null){
parentid=nodexu.id;
}
if(buttonflag=="add_section" || nodexu == null){
parentid="null";
}
var myprojectid="";
var mydocUid="";
var myeditionUid="";
if('${formatEdition.projectId}'!=""){
myprojectid='${formatEdition.projectId}';
}
if('${formatEdition.docUid}'!=""){
mydocUid='${formatEdition.docUid}';
}
if('${ formatEdition.ppmId}'!=""){
myeditionUid='${ formatEdition.ppmId}';
}
//alert(node.text);
$.ajax({
type: "POST",
url: "${contextPath}/pedition/addJc.html",
data: {
previewContent:node.text,
parentid:parentid,
projectId:'${formatEdition.projectId}',
editionUid:'${ formatEdition.ppmId}',
docUid:'${ formatEdition.docUid}'
},
dataType: 'json',
success: function(msg){
buttonflag= "";
$('#tree1').tree('reload');

}
});
}else{
$.ajax({
type: "POST",
url: "${contextPath}/pedition/editJc.html",
data: {
id:node.id,
previewContent:node.text
},
dataType: 'json',
success: function(msg){
buttonflag =="";
$('#tree1').tree('reload');
}
});
}
},
onClick:function(node) {
$('#laHide').hide();
$('#add_sub_section').linkbutton('enable');
$('#add_section').linkbutton('enable');
$('#edit_section').linkbutton('enable');
$('#del_section').linkbutton('enable');
$('#import_work').menubutton('enable');

nodexu=node;
currentNode = node.id;
window.frames["framesouth"].document.location.href='${contextPath}/pedition/toDocItemListView.html?docUid=${ formatEdition.docUid}&docEditionUid=${ formatEdition.ppmId}&isCurrent=${ formatEdition.isCurrent}&sectionUid='+node.id;
},
onBeforeEdit:function(node){
//node.text=node.attributes.truetext.substr(0,node.attributes.truetext.indexOf("("));
//node.text=node.text.substr(0,node.text.indexOf("("));
if(node.attributes!=undefined&&node.attributes.ttext!=undefined){
//alert(node.attributes.ttext+"--22");
node.text=node.attributes.ttext;
}else {
node.text="н¨Õ½Ú";
}
$('#laHide').show();
$('.easyui-linkbutton').linkbutton('disable');
$('.easyui-menubutton').menubutton('disable');
},
onLoadSuccess:function(node, data){
$('#laHide').hide();
var roots = $('#tree1').tree("getRoots");
if(roots.length == 0) {
$('#add_sub_section').linkbutton('disable');
$('#edit_section').linkbutton('disable');
$('#del_section').linkbutton('disable');
$('#import_work').menubutton('disable');
}else {
$('.easyui-linkbutton').linkbutton('enable');
$('.easyui-menubutton').menubutton('enable');
}

if(!currentNode){
$('#tree1').tree("select",roots[0].target);
var selectNode = $('#tree1').tree('getSelected');
window.frames["framesouth"].document.location.href='${contextPath}/pedition/toDocItemListView.html?docUid=${ formatEdition.docUid}&&docEditionUid=${ formatEdition.ppmId}&isCurrent=${ formatEdition.isCurrent}&sectionUid='+selectNode.id;
}else{
var cnode = $('#tree1').tree("find",currentNode);//alert(cnode==null);
if(cnode!=null){
$('#tree1').tree("select",cnode.target);
window.frames["framesouth"].document.location.href='${contextPath}/pedition/toDocItemListView.html?docUid=${ formatEdition.docUid}&&docEditionUid=${ formatEdition.ppmId}&isCurrent=${ formatEdition.isCurrent}&sectionUid='+cnode.id;
}else {
$('#tree1').tree("select",roots[0].target);
var selectNode = $('#tree1').tree('getSelected');
window.frames["framesouth"].document.location.href='${contextPath}/pedition/toDocItemListView.html?docUid=${ formatEdition.docUid}&&docEditionUid=${ formatEdition.ppmId}&isCurrent=${ formatEdition.isCurrent}&sectionUid='+selectNode.id;
}
}
},
onContextMenu: function(e, node){
e.preventDefault();
// ²éÕÒ½Úµã
$('#tree1').tree('select', node.target);
// ÏÔʾ¿ì½Ý²Ëµ¥
$('#mm').menu('show', {
left: e.pageX,
top: e.pageY
});
},
onLoadError:function(arr) {
$('#laHide').show();
$('#add_sub_section').linkbutton('disable');
$('#edit_section').linkbutton('disable');
$('#del_section').linkbutton('disable');
$('#import_work').menubutton('disable');
}

});

上一篇:map.c 添加注释


下一篇:如何在页面中获取到ModelAndView绑定的值