<div id="categoryChooseDiv" title="请选择分类"
style="width: 650px; height: 300px;">
<ul id="MyTree"></ul>
</div>
function showCategory(){
$('#MyTree').tree({
checkbox: false,
url: '/category/getCategorys.java?Id=0',
onBeforeExpand:function(node,param){
$('#MyTree').tree('options').url = "/category/getCategorys.java?Id=" + node.id;
},
onClick:function(node){
var state=node.state;
if(!state){ //判断当前选中的节点是否为根节点
currentId=node.id;
$("#chooseOk").attr( "disabled" , false ); //如果为根节点 则OK按钮可用
}else{
$("#chooseOk").attr( "disabled" , true ); //如果不为根节点 则OK按钮不可用
}
}
});
}
var nodes=[]; //定义数组用来存放各个节点名称
var node =$("#MyTree").tree("getSelected"); //当前选中节点
nodes.push(node.text); //首先放入当前节点
var pnode = $('#MyTree').tree('getParent',node.target); //获取当前节点的父节点
while(pnode!=null){
nodes.push(pnode.text); //依次放入各个父节点,直到根节点为止
pnode = $('#MyTree').tree('getParent',pnode.target);
}
nodes.reverse(); //数组元素倒序排序
$.each(nodes,function(){ //循环取值
var html=this;
$("#inCategoryDiv").html( $("#inCategoryDiv").html() + html + ">>" );
});
public ResponseEntity<String> findBy(Integer Id ) {
List<Category> categorys = getcategorys(Id );
String ss="";
ss+="[";
for( Category category : categorys )
{
ss+="{";
//ss += "\"id\": \""+category.getId()+"\",\"text\": \""+category.getName().toString()+"\",\"iconCls\": \"icon-ok\",\"state\": \"closed\"";;
List<Category> cs = getcategorys( category.getId() ); //判断当前节点是否还有子节点
if(cs.size()==0){ //没有子节点 设置 state 为空
ss+=String.format("\"id\": \"%s\", \"text\": \"%s\", \"iconCls\": \"\", \"state\": \"\"", category.getId() , category.getName());
}else{ // 还有子节点 设置 state为closed
ss+=String.format("\"id\": \"%s\", \"text\": \"%s\", \"iconCls\": \"\", \"state\": \"closed\"", category.getId() , category.getName());
}
ss+="},";
}
ss=ss.substring(0, ss.length() - 1);
ss+="]";
return super.responseString(ss); //字符编码转换
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有