BootStrap
关键点::bootStrap框架不用转换 ,options有个parentcode 它会自动转换
一。后台用get方法查出集合
@GetMapping("/list")
@ResponseBody
public List<SysMenu> list(SysMenu menu)
{
List<SysMenu> menuList = menuService.selectMenuList(menu);
return menuList;
}
二。前台
- table id=“bootstrap-tree-table”
- options有个code, parentCode, uniqueId
- $.treeTable.init(options);
- columns {
field: ‘selectItem’,
radio: true
},
//body
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-tree-table" data-mobile-responsive="true"></table>
</div>
//js
$(function() {
var options = {
code: "deptId",
parentCode: "parentId",
uniqueId: "deptId",
code: "deptId",
parentCode: "parentId",
expandAll: false,
expandFirst: false,
showSearch: false,
showRefresh: false,
showToggle: false,
showColumns: false,
url: prefix + "/list",
modalName: "项目主管部门",
columns: [
{
field: 'selectItem',
radio: true
},
{
field : 'deptId',
title : '部门代码',
formatter: function(value, row, index) {}
}
]
}
$.treeTable.init(options);
EASYUI
关键点:实体有父级,子级,在dao双层查询设置子级
//body
<table id="dg" style="width:96%;height:630px"></table>
//js
$('#dg').treegrid({
url:'findMenuTreeGrid',
striped : true,// 斑马线效果
animate:true,
idField:'menuId',
treeField:'menuName',
pagination: true,
singleSelect : true,
pagination : true, //底部显示分页工具栏。
rownumbers : true, //显示一个行号列。
pageNumber : 1, //第几页显示(默认第一页,可以省略)
pageSize : 10, //分页大小
pageList : [10,20,30,40,50],//设置分页属性的时候 初始化页面大小选择列表。
columns : [ [ {
field : 'menuId',
title : 'ID',
width : 60,
halign:'center'
}, {
field : 'menuName',
title : '菜单名称',
align : 'left',
width : '200'
}
} ] ]
}
//dao接口
List<MenuTreeDto> findMenuTreeGrid(MenuTreeDto menuTreeDto);// 菜单
//mapper.xml
<resultMap id="MenuTreeGridMap" type="com.jwcyzhpt.modules.sys.entity.dto.MenuTreeDto">
<result column="MENU_PERMISSION" jdbcType="VARCHAR" property="menuPermission" />
<result column="USER_ID" jdbcType="VARCHAR" property="userId" />
<collection property="children" fetchType="eager"
ofType="com.jwcyzhpt.modules.sys.entity.dto.MenuTreeDto" column="MENU_ID"
select="findMenuTreeChild">
</collection>
</resultMap>
<select id="findMenuTreeGrid" resultMap="MenuTreeGridMap" parameterType="sys.entity.dto.MenuTreeDto">
select * from from sn_menu
<where>
menu_parentid is null
<if test="menuUrl != null" >nd MENU_URL = #{menuUrl}/if>
</where>
order by menu_seq asc
</select>
<select id="findMenuTreeChild" resultMap="MenuTreeGridMap">
select * from sn_menu where menu_parentid = #{menuId} rder by menu_seq asc
</select>