原創(chuàng)|使用教程|編輯:龔雪|2016-04-18 09:17:54.000|閱讀 1289 次
概述:使用數(shù)據(jù)網(wǎng)格的詳細(xì)視圖,用戶可以展開一行來顯示附加的詳細(xì)信息。任何內(nèi)容都可以加載作為行詳細(xì),子網(wǎng)格也可以動態(tài)加載。本教程將向您展示如何在主網(wǎng)格上創(chuàng)建一個子網(wǎng)格。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Kendo UI for jQuery——創(chuàng)建現(xiàn)代Web應(yīng)用程序的最完整UI庫!查看詳情>>>
使用數(shù)據(jù)網(wǎng)格的詳細(xì)視圖,用戶可以展開一行來顯示附加的詳細(xì)信息。任何內(nèi)容都可以加載作為行詳細(xì),子網(wǎng)格也可以動態(tài)加載。本教程將向您展示如何在主網(wǎng)格上創(chuàng)建一個子網(wǎng)格。
<table id="dg" style="width:700px;height:250px" url="datagrid22_getdata.php" title="DataGrid - SubGrid" singleSelect="true" fitColumns="true"> <thead> <tr> <th field="itemid" width="80">Item ID</th> <th field="productid" width="100">Product ID</th> <th field="listprice" align="right" width="80">List Price</th> <th field="unitcost" align="right" width="80">Unit Cost</th> <th field="attr1" width="220">Attribute</th> <th field="status" width="60" align="center">Status</th> </tr> </thead> </table>
為了使用詳細(xì)視圖,請記得在頁面頭部引用視圖腳本文件。
<script type="text/javascript" src="//www.jeasyui.com/easyui/datagrid-detailview.js"></script>
$('#dg').datagrid({ view: detailview, detailFormatter:function(index,row){ return '<div style="padding:2px"><table class="ddv"></table></div>'; }, onExpandRow: function(index,row){ var ddv = $(this).datagrid('getRowDetail',index).find('table.ddv'); ddv.datagrid({ url:'datagrid22_getdetail.php?itemid='+row.itemid, fitColumns:true, singleSelect:true, rownumbers:true, loadMsg:'', height:'auto', columns:[[ {field:'orderid',title:'Order ID',width:100}, {field:'quantity',title:'Quantity',width:100}, {field:'unitprice',title:'Unit Price',width:100} ]], onResize:function(){ $('#dg').datagrid('fixDetailRowHeight',index); }, onLoadSuccess:function(){ setTimeout(function(){ $('#dg').datagrid('fixDetailRowHeight',index); },0); } }); $('#dg').datagrid('fixDetailRowHeight',index); } });
當(dāng)用戶點擊展開按鈕('+')時,'onExpandRow' 事件將被觸發(fā)。 我們創(chuàng)建一個新的帶有三列的子網(wǎng)格。 當(dāng)子網(wǎng)格數(shù)據(jù)加載成功時或者改變尺寸大小時,請記得對主網(wǎng)格調(diào)用 'fixDetailRowHeight' 方法。
datagrid22_getdata.php
$result = array(); include 'conn.php'; $rs = mysql_query("select * from item where itemid in (select itemid from lineitem)"); $items = array(); while($row = mysql_fetch_object($rs)){ array_push($items, $row); } echo json_encode($items); datagrid22_getdetail.php include 'conn.php'; $itemid = mysql_real_escape_string($_REQUEST['itemid']); $rs = mysql_query("select * from lineitem where itemid='$itemid'"); $items = array(); while($row = mysql_fetch_object($rs)){ array_push($items, $row); } echo json_encode($items);
下載EasyUI示例:
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)