EasyUI 数据网格视图(DataGrid View)

来源:互联网 发布:51单片机中断系统 编辑:程序博客网 时间:2024/06/06 22:17

用法

步骤 1:创建一个 HTML 页面

  1. <head>
  2. <script type="text/javascript" src="datagrid-detailview.js"></script>
  3. </head>
  4. <body>
  5. <table id="tt"></table>
  6. </body>

步骤 2:创建数据网格(DataGrid)

  1. $('#tt').datagrid({
  2. title:'DataGrid - DetailView',
  3. width:500,
  4. height:250,
  5. remoteSort:false,
  6. singleSelect:true,
  7. nowrap:false,
  8. fitColumns:true,
  9. url:'datagrid_data.json',
  10. columns:[[
  11. {field:'itemid',title:'Item ID',width:80},
  12. {field:'productid',title:'Product ID',width:100,sortable:true},
  13. {field:'listprice',title:'List Price',width:80,align:'right',sortable:true},
  14. {field:'unitcost',title:'Unit Cost',width:80,align:'right',sortable:true},
  15. {field:'attr1',title:'Attribute',width:150,sortable:true},
  16. {field:'status',title:'Status',width:60,align:'center'}
  17. ]],
  18. view: detailview,
  19. detailFormatter: function(rowIndex, rowData){
  20. return '<table><tr>' +
  21. '<td rowspan=2 style="border:0"><img src="images/' + rowData.itemid + '.png" style="height:50px;"></td>' +
  22. '<td style="border:0">' +
  23. '<p>Attribute: ' + rowData.attr1 + '</p>' +
  24. '<p>Status: ' + rowData.status + '</p>' +
  25. '</td>' +
  26. '</tr></table>';
  27. }
  28. });

属性

名称类型描述默认值detailFormatterfunction(index,row)返回行明细内容的格式化函数。 

事件

名称参数描述onExpandRowindex,row当展开一行时触发。onCollapseRowindex,row当折叠一行时触发。

方法

名称参数描述fixDetailRowHeightindex固定明细行的高度。getExpanderindex获取行扩展对象。getRowDetailindex获取行明细容器。expandRowindex展开一行。collapseRowindex折叠一行。

数据网格分组视图(DataGrid GroupView)

用法

步骤 1:创建一个 HTML 页面

  1. <head>
  2. <script type="text/javascript" src="datagrid-groupview.js"></script>
  3. </head>
  4. <body>
  5. <table id="tt"></table>
  6. </body>

步骤 2:创建数据网格(DataGrid)

  1. $('#tt').datagrid({
  2. title:'DataGrid - GroupView',
  3. width:500,
  4. height:250,
  5. rownumbers:true,
  6. remoteSort:false,
  7. nowrap:false,
  8. fitColumns:true,
  9. url:'datagrid_data.json',
  10. columns:[[
  11. {field:'productid',title:'Product ID',width:100,sortable:true},
  12. {field:'listprice',title:'List Price',width:80,align:'right',sortable:true},
  13. {field:'unitcost',title:'Unit Cost',width:80,align:'right',sortable:true},
  14. {field:'attr1',title:'Attribute',width:150,sortable:true},
  15. {field:'status',title:'Status',width:60,align:'center'}
  16. ]],
  17. groupField:'productid',
  18. view: groupview,
  19. groupFormatter:function(value, rows){
  20. return value + ' - ' + rows.length + ' Item(s)';
  21. }
  22. });

属性

名称类型描述默认groupFieldstring指示要被分组的字段。 groupFormatterfunction(value,rows)返回分组内容的格式化函数。
value 参数指示由 'groupField' 属性定义的分组值。
rows 参数根据指定分组值指示数据行。 

方法

名称参数描述expandGroupgroupIndex展开一个分组。collapseGroupgroupIndex折叠一个分组。

数据网格缓存视图(DataGrid BufferView)

步骤 1:包含 'datagrid-bufferview.js' 文件

  1. <head>
  2. <script type="text/javascript" src="datagrid-bufferview.js"></script>
  3. </head>

步骤 2:创建数据网格(DataGrid)

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

数据网格虚拟滚动视图(DataGrid VirtualScrollView)

步骤 1:包含 'datagrid-scrollview.js' 文件

  1. <head>
  2. <script type="text/javascript" src="datagrid-scrollview.js"></script>
  3. </head>

步骤 2:通过虚拟滚动视图创建数据网格(DataGrid)

  1. <table id="tt" class="easyui-datagrid" style="width:700px;height:250px" title="DataGrid - VirtualScrollView" data-options="url:'get_data.php',view:scrollview,rownumbers:true,singleSelect:true,autoRowHeight:false,pageSize:50">
  2. <thead>
  3. <tr>
  4. <th field="inv" width="80">Inv No</th>
  5. <th field="date" width="100">Date</th>
  6. <th field="name" width="80">Name</th>
  7. <th field="amount" width="80" align="right">Amount</th>
  8. <th field="price" width="80" align="right">Price</th>
  9. <th field="cost" width="100" align="right">Cost</th>
  10. <th field="note" width="110">Note</th>
  11. </tr>
  12. </thead>
  13. </table>
0 0
原创粉丝点击