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.

130 lines
4.7 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. <div id="cls-Ext.grid.CheckboxSelectionModel"></div>/**
  16. * @class Ext.grid.CheckboxSelectionModel
  17. * @extends Ext.grid.RowSelectionModel
  18. * A custom selection model that renders a column of checkboxes that can be toggled to select or deselect rows.
  19. * @constructor
  20. * @param {Object} config The configuration options
  21. */
  22. Ext.grid.CheckboxSelectionModel = Ext.extend(Ext.grid.RowSelectionModel, {
  23. <div id="cfg-Ext.grid.CheckboxSelectionModel-checkOnly"></div>/**
  24. * @cfg {Boolean} checkOnly <tt>true</tt> if rows can only be selected by clicking on the
  25. * checkbox column (defaults to <tt>false</tt>).
  26. */
  27. <div id="cfg-Ext.grid.CheckboxSelectionModel-header"></div>/**
  28. * @cfg {String} header Any valid text or HTML fragment to display in the header cell for the
  29. * checkbox column. Defaults to:<pre><code>
  30. * '&lt;div class="x-grid3-hd-checker">&#38;#160;&lt;/div>'</tt>
  31. * </code></pre>
  32. * The default CSS class of <tt>'x-grid3-hd-checker'</tt> displays a checkbox in the header
  33. * and provides support for automatic check all/none behavior on header click. This string
  34. * can be replaced by any valid HTML fragment, including a simple text string (e.g.,
  35. * <tt>'Select Rows'</tt>), but the automatic check all/none behavior will only work if the
  36. * <tt>'x-grid3-hd-checker'</tt> class is supplied.
  37. */
  38. header : '<div class="x-grid3-hd-checker">&#160;</div>',
  39. <div id="cfg-Ext.grid.CheckboxSelectionModel-width"></div>/**
  40. * @cfg {Number} width The default width in pixels of the checkbox column (defaults to <tt>20</tt>).
  41. */
  42. width : 20,
  43. <div id="cfg-Ext.grid.CheckboxSelectionModel-sortable"></div>/**
  44. * @cfg {Boolean} sortable <tt>true</tt> if the checkbox column is sortable (defaults to
  45. * <tt>false</tt>).
  46. */
  47. sortable : false,
  48. // private
  49. menuDisabled : true,
  50. fixed : true,
  51. hideable: false,
  52. dataIndex : '',
  53. id : 'checker',
  54. isColumn: true, // So that ColumnModel doesn't feed this through the Column constructor
  55. constructor : function(){
  56. Ext.grid.CheckboxSelectionModel.superclass.constructor.apply(this, arguments);
  57. if(this.checkOnly){
  58. this.handleMouseDown = Ext.emptyFn;
  59. }
  60. },
  61. // private
  62. initEvents : function(){
  63. Ext.grid.CheckboxSelectionModel.superclass.initEvents.call(this);
  64. this.grid.on('render', function(){
  65. Ext.fly(this.grid.getView().innerHd).on('mousedown', this.onHdMouseDown, this);
  66. }, this);
  67. },
  68. /**
  69. * @private
  70. * Process and refire events routed from the GridView's processEvent method.
  71. */
  72. processEvent : function(name, e, grid, rowIndex, colIndex){
  73. if (name == 'mousedown') {
  74. this.onMouseDown(e, e.getTarget());
  75. return false;
  76. } else {
  77. return Ext.grid.Column.prototype.processEvent.apply(this, arguments);
  78. }
  79. },
  80. // private
  81. onMouseDown : function(e, t){
  82. if(e.button === 0 && t.className == 'x-grid3-row-checker'){ // Only fire if left-click
  83. e.stopEvent();
  84. var row = e.getTarget('.x-grid3-row');
  85. if(row){
  86. var index = row.rowIndex;
  87. if(this.isSelected(index)){
  88. this.deselectRow(index);
  89. }else{
  90. this.selectRow(index, true);
  91. this.grid.getView().focusRow(index);
  92. }
  93. }
  94. }
  95. },
  96. // private
  97. onHdMouseDown : function(e, t) {
  98. if(t.className == 'x-grid3-hd-checker'){
  99. e.stopEvent();
  100. var hd = Ext.fly(t.parentNode);
  101. var isChecked = hd.hasClass('x-grid3-hd-checker-on');
  102. if(isChecked){
  103. hd.removeClass('x-grid3-hd-checker-on');
  104. this.clearSelections();
  105. }else{
  106. hd.addClass('x-grid3-hd-checker-on');
  107. this.selectAll();
  108. }
  109. }
  110. },
  111. // private
  112. renderer : function(v, p, record){
  113. return '<div class="x-grid3-row-checker">&#160;</div>';
  114. },
  115. onEditorSelect: function(row, lastRow){
  116. if(lastRow != row && !this.checkOnly){
  117. this.selectRow(row); // *** highlight newly-selected cell and update selection
  118. }
  119. }
  120. });</pre>
  121. </body>
  122. </html>