课程表

jEasyUI 应用

jEasyUI 拖放

jEasyUI 菜单与按钮

jEasyUI 布局

jEasyUI 数据网格

jEasyUI 窗口

jEasyUI 树形菜单

jEasyUI 表单

jEasyUI 参考手册

工具箱
速查手册

jEasyUI 显示海量数据

当前位置:免费教程 » JS/JS库/框架 » jQuery EasyUI

数据网格(datagrid)的虚拟滚动特性可以用来显示大数量的记录而不需要分页。 当滚动垂直滚动条时,数据网格(datagrid)执行 ajax 请求来加载和刷新现有的记录。 整个刷新的行为过程是平稳的没有闪烁。 在本教程中,我们将创建一个数据网格(datagrid),并运用虚拟滚动特性从服务器加载数据。

创建数据网格(DataGrid)

为数据网格(datagrid)运用虚拟滚动特性,'view' 属性应该设置为 'scrollview'。 用户应该从数据网格(datagrid)扩展下载 scrollview,并在页面头部引用 scrollview 文件。

  1. <script type="text/javascript" src="datagrid-detailview.js"></script>
  1. <table id="tt" class="easyui-datagrid" style="width:700px;height:300px"
  2. title="DataGrid - VirtualScrollView"
  3. data-options="view:scrollview,rownumbers:true,singleSelect:true,
  4. url:'datagrid27_getdata.php',autoRowHeight:false,pageSize:50">
  5. <thead>
  6. <tr>
  7. <th field="inv" width="80">Inv No</th>
  8. <th field="date" width="100">Date</th>
  9. <th field="name" width="80">Name</th>
  10. <th field="amount" width="80" align="right">Amount</th>
  11. <th field="price" width="80" align="right">Price</th>
  12. <th field="cost" width="100" align="right">Cost</th>
  13. <th field="note" width="110">Note</th>
  14. </tr>
  15. </thead>
  16. </table>

请注意,这里我们不需要使用 pagination 属性,但 pageSize 属性是必需的,这样执行 ajax 请求时,数据网格(datagrid)将从服务器获取指定数量的记录。

服务器端代码

datagrid27_getdata.php

  1. $page = isset($_POST['page']) ? intval($_POST['page']) : 1;
  2. $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 50;
  3.  
  4. $items = array();
  5. date_default_timezone_set('UTC');
  6. for($i=1; $i<=$rows; $i++){
  7. $index = $i+($page-1)*$rows;
  8. $amount = rand(50,100);
  9. $price = rand(10000,20000)/100;
  10. $items[] = array(
  11. 'inv' => sprintf("INV%04d",$index),
  12. 'date' => date('Y-m-d',time()+24*3600*$i),
  13. 'name' => 'Name' . $index,
  14. 'note' => 'Note' . $index,
  15. 'amount' => $amount,
  16. 'price' => sprintf('%01.2f',$price),
  17. 'cost' => sprintf('%01.2f',$amount*$price)
  18. );
  19. }
  20. $result = array();
  21. $result['total'] = 8000;
  22. $result['rows'] = $items;
  23. echo json_encode($result);

下载 jQuery EasyUI 实例

jeasyui-datagrid-datagrid27.zip

转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号