DataGrid Selection

邹麻雀
2023-12-01
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>DataGrid Selection - jQuery EasyUI Demo</title>
  6. <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
  7. <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
  8. <link rel="stylesheet" type="text/css" href="../demo.css">
  9. <script type="text/javascript" src="../../jquery.min.js"></script>
  10. <script type="text/javascript" src="../../jquery.easyui.min.js"></script>
  11. </head>
  12. <body>
  13. <h2>DataGrid Selection</h2>
  14. <div class="demo-info">
  15. <div class="demo-tip icon-tip"></div>
  16. <div>Choose a selection mode and select one or more rows.</div>
  17. </div>
  18. <div style="margin:10px 0;">
  19. <a href="#" class="easyui-linkbutton" onclick="getSelected()">GetSelected</a>
  20. <a href="#" class="easyui-linkbutton" onclick="getSelections()">GetSelections</a>
  21. </div>
  22. <table id="dg" class="easyui-datagrid" title="DataGrid Selection" style="width:700px;height:250px"
  23. data-options="singleSelect:true,url:'datagrid_data1.json',method:'get'">
  24. <thead>
  25. <tr>
  26. <th data-options="field:'itemid',width:80">Item ID</th>
  27. <th data-options="field:'productid',width:100">Product</th>
  28. <th data-options="field:'listprice',width:80,align:'right'">List Price</th>
  29. <th data-options="field:'unitcost',width:80,align:'right'">Unit Cost</th>
  30. <th data-options="field:'attr1',width:250">Attribute</th>
  31. <th data-options="field:'status',width:60,align:'center'">Status</th>
  32. </tr>
  33. </thead>
  34. </table>
  35. <div style="margin:10px 0;">
  36. <span>Selection Mode: </span>
  37. <select onchange="$('#dg').datagrid({singleSelect:(this.value==0)})">
  38. <option value="0">Single Row</option>
  39. <option value="1">Multiple Rows</option>
  40. </select>
  41. </div>
  42. <script type="text/javascript">
  43. function getSelected(){
  44. var row = $('#dg').datagrid('getSelected');
  45. if (row){
  46. $.messager.alert('Info', row.itemid+":"+row.productid+":"+row.attr1);
  47. }
  48. }
  49. function getSelections(){
  50. var ss = [];
  51. var rows = $('#dg').datagrid('getSelections');
  52. for(var i=0; i<rows.length; i++){
  53. var row = rows[i];
  54. ss.push('<span>'+row.itemid+":"+row.productid+":"+row.attr1+'</span>');
  55. }
  56. $.messager.alert('Info', ss.join('<br/>'));
  57. }
  58. </script>
  59. </body>
  60. </html>
 类似资料:

相关阅读

相关文章

相关问答