EasyUI折疊表格層次顯示detailview詳解及實例
本文目的:
使用easyUi的特殊常用實例,表格層次顯示,一層套一層,顯示詳細數(shù)據(jù),嵌套3層應(yīng)該可以滿足所有人的需求了吧。如果你想嵌套4層,有了嵌套3層的案例,4層,5層不是問題吧!?。?/p>
本實例的特點:
1.當(dāng)數(shù)據(jù)很多的時候,高度不能自動適應(yīng),會在表格右側(cè)出現(xiàn)滾動條,想這樣嵌套3層的后果,簡直不忍直視,本實例高度自適應(yīng)。
2.選中行后,不能清除選中效果,本實例是可以的。
3.當(dāng)打開數(shù)據(jù)展示詳情后,再關(guān)閉詳情頁后,不能高度自適應(yīng),本實例關(guān)閉表格依然自適應(yīng)。
4.當(dāng)數(shù)據(jù)太多,需要出現(xiàn)橫向滾動,本實例已給出詳細案例。
首先一張圖片,展示效果,是否和自己的預(yù)期一致。
本實例的下載地址:http://download.csdn.net/detail/meng564764406/9723582
實例內(nèi)容,包含了源代碼,包含了所要使用js、css、圖片文件。
下面開始引入我們需要的css文件
<link rel="stylesheet" type="text/css" href="jquery-easyui-1.3.5/themes/icon.css" /> <link rel="stylesheet" type="text/css" href="jquery-easyui-1.3.5/themes/gray/easyui.css" />
下面引入我們需要的js文件
<script type="text/javascript" src="js/jquery/jquery-1.7.2.min.js"></script> <script type="text/javascript" src="jquery-easyui-1.3.5/jquery-1.3.5.easyui.min.js"></script> <script type="text/javascript" src="js/jquery/datagrid-detailview.js" charset="utf-8"></script>
查看我們的body標(biāo)簽中的代碼
<table id="dg" url="json/datagrid_data.json" title="收款管理" singleSelect="false" fitColumns="true"> <thead> <tr> <th field="inv" width="80">部門</th> <th field="date" width="100">日期</th> <th field="name" align="right" width="80">名字</th> <th field="amount" align="right" width="80">數(shù)量</th> <th field="note" width="220">小計</th> </tr> </thead> </table>
我們自己編寫的js代碼
<script type="text/javascript"> $(function(){ $('#dg').datagrid({ view: detailview, detailFormatter:function(index,row){//嚴(yán)重注意喔 return '<div"><table id="ddv-' + index + '" ></table></div>'; }, onExpandRow: function(index,row){//嵌套第一層,嚴(yán)重注意喔 var ddv = $(this).datagrid('getRowDetail',index).find('#ddv-'+index);//嚴(yán)重注意喔 ddv.datagrid({ view: detailview, url:'json/datagrid_data.json', autoRowHeight:true, fitColumns:true,//改變橫向滾動條 singleSelect:false,//去掉選中效果 rownumbers:true, loadMsg:'', // height:'auto', columns:[[ {field:'inv',title:'年份',width:100}, {field:'date',title:'應(yīng)收',width:100}, {field:'name',title:'合同款',width:100}, {field:'amount',title:'已收',width:100}, {field:'note',title:'比例',width:100} ]], detailFormatter:function(index,row2){//嚴(yán)重注意喔 return '<div"><table id="ddv2-' + index + '" style=""></table></div>'; }, onExpandRow: function(index2,row2){//嵌套第二層,嚴(yán)重注意喔 var ddv2 = $(this).datagrid('getRowDetail',index2).find('#ddv2-'+index2);//嚴(yán)重注意喔 ddv2.datagrid({ view: detailview, url:'json/datagrid_data.json', autoRowHeight:true, fitColumns:true, singleSelect:false, rownumbers:true, loadMsg:'', // height:'auto', columns:[[ {field:'inv',title:'月份',width:100}, {field:'date',title:'應(yīng)收',width:100,align:'right'}, {field:'name',title:'合同款',width:100,align:'right'}, {field:'amount',title:'已收',width:100,align:'right'}, {field:'note',title:'比例',width:100,align:'right'} ]], detailFormatter:function(index2,row3){//嚴(yán)重注意喔 return '<div"><table id="ddv3-' + index2 + '" style=""></table></div>'; }, onExpandRow: function(index3,row3){//嵌套第三層,嚴(yán)重注意喔 var ddv3 = $(this).datagrid('getRowDetail',index3).find('#ddv3-'+index3);//嚴(yán)重注意喔 ddv3.datagrid({//嚴(yán)重注意喔 這里沒有detailview了哈 url:'json/datagrid_data3.json', autoRowHeight:true, fitColumns:false,// singleSelect:false, rownumbers:true, loadMsg:'', // height:'auto', columns:[[ {field:'aaa',title:'項目名稱',width:100}, {field:'bbb',title:'合同編號',width:100,align:'right'}, {field:'ccc',title:'合同名稱',width:100,align:'right'}, {field:'ddd',title:'款數(shù)',width:100,align:'right'}, {field:'eee',title:'技術(shù)負責(zé)人',width:50,align:'right'}, {field:'fff',title:'條件具備日期',width:100,align:'right'}, {field:'ggg',title:'銷售',width:50,align:'right'}, {field:'hhh',title:'收款計劃日期',width:100,align:'right'}, {field:'iii',title:'計劃收款比例',width:100,align:'right'}, {field:'jjj',title:'實際收款比例',width:100,align:'right'}, {field:'kkk',title:'差距',width:80,align:'right'}, {field:'lll',title:'銷售說明',width:100,align:'right'}, <span style="white-space:pre"> </span> {field:'mmm',title:'收款金額',width:100,align:'right'}, {field:'nnn',title:'詳情',width:100,align:'right'} ]], detailFormatter:function(index3,row){//嚴(yán)重注意喔 return '<div style="padding:2px"><table id="ddv3-' + index3 + '"></table></div>';//嚴(yán)重注意喔 }, onResize:function(){//嚴(yán)重注意喔 ddv2.datagrid('fixDetailRowHeight',index3); ddv.datagrid('fixDetailRowHeight',index2); $('#dg').datagrid('fixDetailRowHeight',index); }, onLoadSuccess:function(){ setTimeout(function(){//嚴(yán)重注意喔 ddv2.datagrid('fixDetailRowHeight',index3); ddv2.datagrid('fixRowHeight',index3); ddv.datagrid('fixDetailRowHeight',index2); ddv.datagrid('fixRowHeight',index2); $('#dg').datagrid('fixDetailRowHeight',index); $('#dg').datagrid('fixRowHeight',index); },0); } });//嚴(yán)重注意喔 ddv2.datagrid('fixDetailRowHeight',index); ddv.datagrid('fixDetailRowHeight',index); $('#dg').datagrid('fixDetailRowHeight',index); }, onCollapseRow: function(index3,row3){//嚴(yán)重注意喔 var ddv3 = $(this).datagrid('getRowDetail',index3).find('#ddv3-'+index3); ddv3.datagrid({ onResize:function(){ ddv2.datagrid('fixDetailRowHeight',index3); <span style="white-space:pre"> </span> ddv.datagrid('fixDetailRowHeight',index2); $('#dg').datagrid('fixDetailRowHeight',index); } });//嚴(yán)重注意喔 ddv2.datagrid('fixDetailRowHeight',index); ddv.datagrid('fixDetailRowHeight',index); $('#dg').datagrid('fixDetailRowHeight',index); }, onResize:function(){//嚴(yán)重注意喔 ddv.datagrid('fixDetailRowHeight',index2); $('#dg').datagrid('fixDetailRowHeight',index); }, onLoadSuccess:function(){//嚴(yán)重注意喔 setTimeout(function(){ ddv.datagrid('fixDetailRowHeight',index2); ddv.datagrid('fixRowHeight',index2); $('#dg').datagrid('fixDetailRowHeight',index); $('#dg').datagrid('fixRowHeight',index); },0); } });//嚴(yán)重注意喔 ddv.datagrid('fixDetailRowHeight',index2); $('#dg').datagrid('fixDetailRowHeight',index); }, onCollapseRow: function(index2,row2){//嚴(yán)重注意喔 var ddv2 = $(this).datagrid('getRowDetail',index2).find('#ddv2-'+index2); ddv2.datagrid({ onResize:function(){ ddv.datagrid('fixDetailRowHeight',index2); $('#dg').datagrid('fixDetailRowHeight',index); } });//嚴(yán)重注意喔 ddv.datagrid('fixDetailRowHeight',index2); $('#dg').datagrid('fixDetailRowHeight',index); }, onResize:function(){ $('#dg').datagrid('fixDetailRowHeight',index); }, onLoadSuccess:function(){ setTimeout(function(){ $('#dg').datagrid('fixDetailRowHeight',index); $('#dg').datagrid('fixRowHeight',index); },0); } }); $('#dg').datagrid('fixDetailRowHeight',index); } }); }); </script>
以上所述是小編給大家介紹的EasyUI折疊表格層次顯示detailview詳解及實例,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
- easyUI使用分頁過濾器對數(shù)據(jù)進行分頁操作實例分析
- jQuery EasyUI API 中文文檔 - Pagination分頁
- jQuery EasyUI datagrid實現(xiàn)本地分頁的方法
- jQuery EasyUI Pagination實現(xiàn)分頁的常用方法
- EasyUi datagrid 實現(xiàn)表格分頁
- EasyUI Pagination 分頁的兩種做法小結(jié)
- SSh結(jié)合Easyui實現(xiàn)Datagrid的分頁顯示
- EasyUi+Spring Data 實現(xiàn)按條件分頁查詢的實例代碼
- EasyUI加載完Html內(nèi)容樣式渲染完成后顯示
- jQuery Easyui學(xué)習(xí)教程之實現(xiàn)datagrid在沒有數(shù)據(jù)時顯示相關(guān)提示內(nèi)容
- easyUI 實現(xiàn)的后臺分頁與前臺顯示功能示例
相關(guān)文章
jquery+css實現(xiàn)側(cè)邊導(dǎo)航欄效果
這篇文章主要為大家詳細介紹了jquery+css實現(xiàn)側(cè)邊導(dǎo)航欄效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-06-06jQuery關(guān)鍵詞說明插件cluetip使用指南
我們在做web項目的時候,經(jīng)常會使用到提示效果。html自帶的提示效果是label標(biāo)簽的title,但是這個效果過于簡單和難看,并且不方便調(diào)整樣式。今天我偶然發(fā)現(xiàn)個jQuery的插件,可以很方便的做出漂亮的提示效果。2015-04-04jQuery實現(xiàn)鼠標(biāo)滑過Div層背景變顏色的方法
這篇文章主要介紹了jQuery實現(xiàn)鼠標(biāo)滑過Div層背景變顏色的方法,涉及jQuery中hover及addClass方法的使用技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-02-02利用JQuery動畫制作滑動菜單項效果實現(xiàn)步驟及代碼
滑動菜單項效果,聽起來就是很時尚的一個效果,不過實現(xiàn)起來有些麻煩,還好有本文的出現(xiàn),可以幫助你解決這個困惑,熱愛特效的你可不要錯過了哈,好了話不多說切入正文2013-02-02