本篇內(nèi)容主要講解“l(fā)ayui+java怎么實(shí)現(xiàn)樹形表格”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實(shí)用性強(qiáng)。下面就讓小編來帶大家學(xué)習(xí)“l(fā)ayui+java怎么實(shí)現(xiàn)樹形表格”吧!
賓縣網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián),賓縣網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為賓縣數(shù)千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站制作要多少錢,請找那個售后服務(wù)好的賓縣做網(wǎng)站的公司定做!
treeTable 模塊下載: https://gitee.com/whvse/treetable-lay/tree/master/2.x
下載后,treeTable.js、treeTable.css 的放置目錄分別為: layuiadmin/modules/treeTable.js layuiadmin/modules/treeTable/treeTable.css
頁面元素:
<div > <table class="layui-hide" id="businessConfigListTable" lay-filter="businessConfigListTable"></table> </div>
定義:
layui.config({ base: '${ctxLayui}/layuiadmin/' }).extend({ index: 'lib/index' }).use(['index', 'table','dict','laydate','util','treeTable'], function(){ var $ = layui.$,table = layui.table,form = layui.form; var dict = layui.dict; var laydate = layui.laydate; var admin = layui.admin; var util = layui.util; var treeTable = layui.treeTable;
渲染:
var insTb = treeTable.render({ elem: '#businessConfigListTable', tree: { iconIndex: 1, // 折疊圖標(biāo)顯示在第幾列 idName: 'id', // 自定義id字段的名稱 pidName: 'parentId', // 自定義標(biāo)識是否還有子節(jié)點(diǎn)的字段名稱 }, cols: [ {type: 'checkbox', fixed: 'left'}, {type: 'numbers',width: 120,style:'text-align:left'}, // {field: 'id', title: 'ID',width: 180}, {field: 'type', title: '類型', width: 120,templet:tplType}, {field: 'name', title: '名稱', width: 200}, {field: 'value', title: '值'}, {field: 'sortOrder', title: '排序', width: 120}, {field: 'status', title: '狀態(tài)', width: 150,templet:tplStatus}, {title:'操作', toolbar: '#businessConfigListTable-bar', width:120} ], reqData: function(data, callback) { // 在這里寫ajax請求,通過callback方法回調(diào)數(shù)據(jù) var url = ctx+'/business/businessConfig/businessConfigTreeList'; var rtn = admin.syncReq(url,{}); var rtnData = rtn.data; for(var i=0;i<rtnData.length;i++){ var vo = rtnData[i]; vo.open = true; } callback(rtnData); } ,height: 'full-99' });
接口:business/businessConfig/businessConfigTreeList, 如下:
@RequestMapping(value = "businessConfigTreeList") @ResponseBody public BaseResp businessConfigTreeList(@ModelAttribute("command") BusinessConfigQo command){ BaseResp resp = new BaseResp(); try{ List<BusinessConfigPo> list = businessConfigService.businessConfigTreeList(command); resp.setData(list); }catch (Exception e){ error(logger,resp,e); } return resp; }
其中 BaseResp 結(jié)構(gòu):
/** * 應(yīng)答返回碼 */ private int code = RC_OK; /** * 應(yīng)答返回消息 */ private String msg; /** * 跳轉(zhuǎn)url */ private String url = ""; private int count; private boolean success = false;// 是否成功 private Object data;
service層獲取數(shù)據(jù),遞歸:
public List<BusinessConfigPo> businessConfigTreeList(BusinessConfigQo command) throws Exception{ command.setParentId(0l); command.setLimit(99999); List<BusinessConfigPo> list = this.businessConfigMapper.query(command); for(BusinessConfigPo rec:list){ List<BusinessConfigPo> children = getChildrenConfig(rec); rec.setChildren(children); } return list; } private List<BusinessConfigPo> getChildrenConfig(BusinessConfigPo rec) throws Exception{ BusinessConfigQo qo = new BusinessConfigQo(); qo.setLimit(99999); qo.setParentId(rec.getId()); List<BusinessConfigPo> list = this.businessConfigMapper.query(qo); if(list==null){ return null; } for(BusinessConfigPo child:list){ List<BusinessConfigPo> children = getChildrenConfig(child); child.setChildren(children); } return list; }
到此,相信大家對“l(fā)ayui+java怎么實(shí)現(xiàn)樹形表格”有了更深的了解,不妨來實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
當(dāng)前題目:layui+java怎么實(shí)現(xiàn)樹形表格
分享網(wǎng)址:http://muchs.cn/article46/gjseeg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營銷型網(wǎng)站建設(shè)、網(wǎng)站策劃、網(wǎng)站設(shè)計(jì)、移動網(wǎng)站建設(shè)、小程序開發(fā)、動態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)