<@fkMacros.pageHeaderBegin />
<script language="javascript">
window.SITE_URL ='${resourcePath}';
</script>
<link rel="stylesheet" type="text/css" href="${resourcePath}/js/treeTable/vsStyle/jquery.treeTable.css" />
<script src="${resourcePath}/js/treeTable/jquery.treeTable.js" type="text/javascript"></script>
<@fkMacros.pageHeaderEnd />
<@fkMacros.lhgDialog />
<script language="javascript">
var $treeTable=null;
$(document).ready(function(){
$treeTable=$('#tableList').treeTable({
theme:'vsStyle',
expandLevel : 1,
url:'lawCalling_loadTree.xhtml?fatherId=',
callback:function(item) {
var result= '<td style="text-align:left">'+item.name+'</td>'+
'<td >'+(item.modifyTime).replace("T"," ")+'</td>'+
'<td class="align-left" >'+
'【<a href="javascript:openURL(\'${contextPath}/lawCalling/lawCalling_info.xhtml?lawCalling.fatherId='+item.id+'\',\'新建【'+item.name+'】子模块\',\'addson'+item.id+'\',400,150)">添加子分类</a>】'+
'【<a href="javascript:openURL(\'${contextPath}/lawCalling/lawCalling_info.xhtml?lawCalling.id='+item.id+'\',\'编辑行业分类\',\'modify'+item.id+'\',400,150)">修改</a>】'+
'【<a onclick="del('+item.id+',this)" href="javascript:;">删除</a>】'+
'<a href="javascript:;" onclick="sort('+item.id+',true);">向上</a>'+
'<a href="javascript:;" onclick="sort('+item.id+',false);">向下</a>'+
'</td>';
return result;
},
beforeClick: function($treeTable, id) {
//异步获取数据 这里模拟替换处理
$treeTable.refreshPoint(id);
},
beforeExpand : function($treeTable, id) {
},
beforeClose : function($treeTable, id) {
}
});
});
function del(id,con){
if(confirm(' 确认要删除吗?')){
$.ajax({
url:'lawCalling_del.xhtml',
data:"lawCalling.id="+id,
type:"GET",
cache:false,
async:false,
dateType:"json",
error:function(XMLHttpRequest,textStatus) {
alert('服务器连接失败,请稍候重试!');
},
success: function(response){
if(!response.success){
alert(response.message);
return;
}
var pId=$(con).parents('tr').attr("pId");
var $t=$(con).parents('table').find("tr[id='"+pId+"']");
$($(con).parents('tr')[0]).remove();
$treeTable.initMap($t.parents('table').find("tr"));
$treeTable.initChild($t,true);
$treeTable.open($t.attr("pId"));
$treeTable.expand($t);
}
});
}
}
var reload=function(id) {
if(id)
$treeTable.refreshPoint(id);
}
function sort(id,isUpSort){
var success=ajax('lawCalling_sortNum.xhtml',"lawCalling.id="+id+"&upSort="+isUpSort);
if(success){
var $ctr=$("tr[id='"+id+"']",$treeTable);
var $trs=null;
if($ctr.attr("pId")!=null)
$trs=$("tr[pId='"+$ctr.attr("pId")+"']",$treeTable);
else
$trs=$("tr[depth='1']",$treeTable);
if($trs.size()>1) {
//递归深度
if(isUpSort) {
if($trs[0].id==$ctr[0].id){alert("已经置顶了!"); return;}
var i=0;
$trs.each(function(k){
if(this.id==$ctr[0].id) i=k;
});
var $ptr=$($trs[i-1]);
//封装
var indexB=0,indexE=0,depth=parseInt($ctr.attr("depth"),10);
var $alltrs=$("tr",$treeTable);
for(var k=0;k<$alltrs.size();k++)
{
if($alltrs[k].id==$ctr[0].id) {
indexB=k;
} else if(indexB>0&&parseInt($($alltrs[k]).attr("depth"),10)>depth) {
indexE=k;
} else if(indexB>0&&parseInt($($alltrs[k]).attr("depth"),10)<=depth) {
break;
}
}
var selector="tr:eq("+indexB+")";
indexB++;
while(indexB<=indexE) {
selector+=",tr:eq("+indexB+")";
indexB++;
}
//交换
$(selector,$treeTable).insertBefore($ptr);
}else {
if($trs[$trs.size()-1].id==$ctr[0].id){alert("已经末端了!"); return;}
var i=0;
$trs.each(function(k){
if(this.id==$ctr[0].id) i=k;
});
var $ntr=$($trs[i+1]);
//封装
var indexB=0,indexE=0,depth=parseInt($ntr.attr("depth"),10);
var $alltrs=$("tr",$treeTable);
for(var k=0;k<$alltrs.size();k++)
{
if($alltrs[k].id==$ntr[0].id) {
indexB=k;
} else if(indexB>0&&parseInt($($alltrs[k]).attr("depth"),10)>depth) {
indexE=k;
} else if(indexB>0&&parseInt($($alltrs[k]).attr("depth"),10)<=depth) {
break;
}
}
var selector="tr:eq("+indexB+")";
indexB++;
while(indexB<=indexE) {
selector+=",tr:eq("+indexB+")";
indexB++;
}
//交换
$(selector,$treeTable).insertBefore($ctr);
}
//$treeTable.initMap($treeTable.find("tr"));
}
} else {
alert("移动失败!");
}
}
function ajax(url,data){
var success;
$.ajax({
url:url,
data:data,
type:"GET",
cache:false,
async:false,
dateType:"json",
error:function(XMLHttpRequest,textStatus) {
alert('服务器连接失败,请稍候重试!');
success=false;
},
success: function(response){
if(response.message!==null){
//alert(response.msg);
}
if(!response.success){
success=false;
return;
}
success=true;
}
});
return success;
}
</SCRIPT>
<#escape x as (x)!>
<div class="Current_bg"><div class="Current">行业分类管理</div></div>
<table width="98%" border="0" cellpadding="0" cellspacing="0" class="list_menu margin" height="30" align="center">
<tr>
<td align="right"><a href="javascript:openURL('${contextPath}/lawCalling/lawCalling_info.xhtml?lawCalling.fatherId=-1','添加顶级行业','top',400,150)">添加顶级行业</a></td>
<td width="30"></td>
</tr>
</table>
<table width="98%" id="tableList" border="0" cellspacing="0" cellpadding="0" class="list" align="center">
<thead>
<tr>
<th width="32%">行业名称</th>
<th width="13%">创建时间</th>
<th width="55%">操作</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<#if lawCallingList?size==0>
<tr>
<td colspan="4" style="text-align:center;">此列表没有任何数据!</td>
</tr>
</#if>
</tfoot>
</table>
</#escape>
<@fkMacros.pageFooter />
public List<LawCalling> loadLawCallingTreeByFatherId(Long id){
String hql = "select new LawCalling(id,fatherId,name,modifyTime,(select case when count(*) = 0 then 'false' else 'true' end from LawCalling " +
"where fatherId = f.id and deleted=0) as haschild ) from LawCalling f where f.fatherId="+id+" and f.deleted=0 order by f.sortNum asc ";
return lawCallingPersistence.findByHql(hql,null);
}
分享到:
相关推荐
jquery treetable树形表格菜单插件
使用起来代码很简单 效果很不错 快下吧
jquery.treeTable.js jquery.treeTable.js jquery.treeTable.js jquery.treeTable.js jquery.treeTable.js jquery.treeTable.js
treetable这个jquery插件 的演示demo,带完整的jquery,treetable和css依赖
Jquery的treeTable实现树型结构显示数据,里面有官方Demo以及我写的一个Demo便于理解,希望对你们有所帮助
用jQuery的treetable实现的树形table
treetable这个jquery插件 的演示demo,带完整的jquery,treetable和css依赖
jQuery树型表格jquery-treetable
整理的27款jQuery Tree 插件,内容包括适应浏览器,是否开源,优缺点,使用方法,效果图等,供大家查阅。
jquery.treetable,.js下载.基于jquery的表格插件,table,表格,treetable,资源下载
jqery.treeTable + ajax + mysql数据库, ssm架构构建树形表格
jQuery_treetable实现checkbox树,实现多级联动,适用于权限树等各类需要树形结构数据的场景
treeTable V1.0 博文链接:https://zhanchaojiang.iteye.com/blog/1036454
Layui、treeTable、树形表格、无限层级
简单实用的树形菜单,可以嵌入任何项目里面,样式适合,很大气漂亮的树树形菜单。实在是不能上传图片,不然就传张实例 图片上来了
树形表格,基于javascript的树状菜单和表格控件
对网上的树形表格treeTable进行了二次开发扩展,带演示demo例子
jquery TreeTable代码示例
jQuery treetable是jQuery的插件,“少写,多做,JavaScript库”。 使用此插件,您可以在HTML表中显示树,例如目录结构或嵌套列表。 您为什么不使用列表? 因为列表非常适合显示树,而表却不适合。 哦,等等,但是...