原創(chuàng)|使用教程|編輯:龔雪|2016-04-21 09:27:50.000|閱讀 1354 次
概述:數(shù)據(jù)網(wǎng)格的虛擬滾動(dòng)功能可以用來(lái)顯示大量的數(shù)據(jù)記錄而無(wú)需分頁(yè)。當(dāng)滾動(dòng)條垂直滾動(dòng)時(shí),數(shù)據(jù)網(wǎng)格執(zhí)行Ajax請(qǐng)求來(lái)加載和刷新現(xiàn)有的記錄。整個(gè)刷新的操作過(guò)程是平穩(wěn)無(wú)閃爍的。在本教程中,我們將創(chuàng)建一個(gè)數(shù)據(jù)網(wǎng)格,并運(yùn)用虛擬滾動(dòng)功能從服務(wù)器中加載數(shù)據(jù)。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷(xiāo)售中 >>
相關(guān)鏈接:
Kendo UI for jQuery——?jiǎng)?chuàng)建現(xiàn)代Web應(yīng)用程序的最完整UI庫(kù)!查看詳情>>>
數(shù)據(jù)網(wǎng)格的虛擬滾動(dòng)功能可以用來(lái)顯示大量的數(shù)據(jù)記錄而無(wú)需分頁(yè)。當(dāng)滾動(dòng)條垂直滾動(dòng)時(shí),數(shù)據(jù)網(wǎng)格執(zhí)行Ajax請(qǐng)求來(lái)加載和刷新現(xiàn)有的記錄。整個(gè)刷新的操作過(guò)程是平穩(wěn)無(wú)閃爍的。在本教程中,我們將創(chuàng)建一個(gè)數(shù)據(jù)網(wǎng)格,并運(yùn)用虛擬滾動(dòng)功能從服務(wù)器中加載數(shù)據(jù)。
想要應(yīng)用數(shù)據(jù)網(wǎng)格的虛擬滾動(dòng)功能,將'view' 屬性設(shè)置為'scrollview'。用戶從數(shù)據(jù)網(wǎng)格的擴(kuò)展中下載scrollview,同時(shí)在頁(yè)面頭部引用scrollview文件。
<script type="text/javascript" src="//www.jeasyui.com/easyui/datagrid-scrollview.js"></script>
<table id="tt" class="easyui-datagrid" style="width:700px;height:300px" title="DataGrid - VirtualScrollView" data-options="view:scrollview,rownumbers:true,singleSelect:true, url:'datagrid27_getdata.php',autoRowHeight:false,pageSize:50"> <thead> <tr> <th field="inv" width="80">Inv No</th> <th field="date" width="100">Date</th> <th field="name" width="80">Name</th> <th field="amount" width="80" align="right">Amount</th> <th field="price" width="80" align="right">Price</th> <th field="cost" width="100" align="right">Cost</th> <th field="note" width="110">Note</th> </tr> </thead> </table>
請(qǐng)注意在這里我們不需要使用pagination屬性,但pageSize屬性是必需的,這樣執(zhí)行ajax請(qǐng)求時(shí)數(shù)據(jù)網(wǎng)格將從服務(wù)器獲取指定數(shù)量的記錄。
datagrid27_getdata.php
$page = isset($_POST['page']) ? intval($_POST['page']) : 1; $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 50; $items = array(); date_default_timezone_set('UTC'); for($i=1; $i<=$rows; $i++){ $index = $i+($page-1)*$rows; $amount = rand(50,100); $price = rand(10000,20000)/100; $items[] = array( 'inv' => sprintf("INV%04d",$index), 'date' => date('Y-m-d',time()+24*3600*$i), 'name' => 'Name' . $index, 'note' => 'Note' . $index, 'amount' => $amount, 'price' => sprintf('%01.2f',$price), 'cost' => sprintf('%01.2f',$amount*$price) ); } $result = array(); $result['total'] = 8000; $result['rows'] = $items; echo json_encode($result);
下載EasyUI示例:
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)