Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.9 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>The source code</title>
  5. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  6. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  7. </head>
  8. <body onload="prettyPrint();">
  9. <pre class="prettyprint lang-js">/*!
  10. * Ext JS Library 3.3.1
  11. * Copyright(c) 2006-2010 Sencha Inc.
  12. * licensing@sencha.com
  13. * http://www.sencha.com/license
  14. */
  15. Ext.ns('Ext.ux.grid');
  16. /**
  17. * @class Ext.ux.grid.TableGrid
  18. * @extends Ext.grid.GridPanel
  19. * A Grid which creates itself from an existing HTML table element.
  20. * @history
  21. * 2007-03-01 Original version by Nige "Animal" White
  22. * 2007-03-10 jvs Slightly refactored to reuse existing classes * @constructor
  23. * @param {String/HTMLElement/Ext.Element} table The table element from which this grid will be created -
  24. * The table MUST have some type of size defined for the grid to fill. The container will be
  25. * automatically set to position relative if it isn't already.
  26. * @param {Object} config A config object that sets properties on this grid and has two additional (optional)
  27. * properties: fields and columns which allow for customizing data fields and columns for this grid.
  28. */
  29. Ext.ux.grid.TableGrid = function(table, config){
  30. config = config ||
  31. {};
  32. Ext.apply(this, config);
  33. var cf = config.fields || [], ch = config.columns || [];
  34. table = Ext.get(table);
  35. var ct = table.insertSibling();
  36. var fields = [], cols = [];
  37. var headers = table.query("thead th");
  38. for (var i = 0, h; h = headers[i]; i++) {
  39. var text = h.innerHTML;
  40. var name = 'tcol-' + i;
  41. fields.push(Ext.applyIf(cf[i] ||
  42. {}, {
  43. name: name,
  44. mapping: 'td:nth(' + (i + 1) + ')/@innerHTML'
  45. }));
  46. cols.push(Ext.applyIf(ch[i] ||
  47. {}, {
  48. 'header': text,
  49. 'dataIndex': name,
  50. 'width': h.offsetWidth,
  51. 'tooltip': h.title,
  52. 'sortable': true
  53. }));
  54. }
  55. var ds = new Ext.data.Store({
  56. reader: new Ext.data.XmlReader({
  57. record: 'tbody tr'
  58. }, fields)
  59. });
  60. ds.loadData(table.dom);
  61. var cm = new Ext.grid.ColumnModel(cols);
  62. if (config.width || config.height) {
  63. ct.setSize(config.width || 'auto', config.height || 'auto');
  64. }
  65. else {
  66. ct.setWidth(table.getWidth());
  67. }
  68. if (config.remove !== false) {
  69. table.remove();
  70. }
  71. Ext.applyIf(this, {
  72. 'ds': ds,
  73. 'cm': cm,
  74. 'sm': new Ext.grid.RowSelectionModel(),
  75. autoHeight: true,
  76. autoWidth: false
  77. });
  78. Ext.ux.grid.TableGrid.superclass.constructor.call(this, ct, {});
  79. };
  80. Ext.extend(Ext.ux.grid.TableGrid, Ext.grid.GridPanel);
  81. //backwards compat
  82. Ext.grid.TableGrid = Ext.ux.grid.TableGrid;
  83. </pre>
  84. </body>
  85. </html>