Web UI for ARGUS server
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.

683 lines
33 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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.Column"></div>/**
  16. * @class Ext.grid.Column
  17. * <p>This class encapsulates column configuration data to be used in the initialization of a
  18. * {@link Ext.grid.ColumnModel ColumnModel}.</p>
  19. * <p>While subclasses are provided to render data in different ways, this class renders a passed
  20. * data field unchanged and is usually used for textual columns.</p>
  21. */
  22. Ext.grid.Column = Ext.extend(Ext.util.Observable, {
  23. <div id="cfg-Ext.grid.Column-editable"></div>/**
  24. * @cfg {Boolean} editable Optional. Defaults to <tt>true</tt>, enabling the configured
  25. * <tt>{@link #editor}</tt>. Set to <tt>false</tt> to initially disable editing on this column.
  26. * The initial configuration may be dynamically altered using
  27. * {@link Ext.grid.ColumnModel}.{@link Ext.grid.ColumnModel#setEditable setEditable()}.
  28. */
  29. <div id="cfg-Ext.grid.Column-id"></div>/**
  30. * @cfg {String} id Optional. A name which identifies this column (defaults to the column's initial
  31. * ordinal position.) The <tt>id</tt> is used to create a CSS <b>class</b> name which is applied to all
  32. * table cells (including headers) in that column (in this context the <tt>id</tt> does not need to be
  33. * unique). The class name takes the form of <pre>x-grid3-td-<b>id</b></pre>
  34. * Header cells will also receive this class name, but will also have the class <pre>x-grid3-hd</pre>
  35. * So, to target header cells, use CSS selectors such as:<pre>.x-grid3-hd-row .x-grid3-td-<b>id</b></pre>
  36. * The {@link Ext.grid.GridPanel#autoExpandColumn} grid config option references the column via this
  37. * unique identifier.
  38. */
  39. <div id="cfg-Ext.grid.Column-header"></div>/**
  40. * @cfg {String} header Optional. The header text to be used as innerHTML
  41. * (html tags are accepted) to display in the Grid view. <b>Note</b>: to
  42. * have a clickable header with no text displayed use <tt>'&amp;#160;'</tt>.
  43. */
  44. <div id="cfg-Ext.grid.Column-groupable"></div>/**
  45. * @cfg {Boolean} groupable Optional. If the grid is being rendered by an {@link Ext.grid.GroupingView}, this option
  46. * may be used to disable the header menu item to group by the column selected. Defaults to <tt>true</tt>,
  47. * which enables the header menu group option. Set to <tt>false</tt> to disable (but still show) the
  48. * group option in the header menu for the column. See also <code>{@link #groupName}</code>.
  49. */
  50. <div id="cfg-Ext.grid.Column-groupName"></div>/**
  51. * @cfg {String} groupName Optional. If the grid is being rendered by an {@link Ext.grid.GroupingView}, this option
  52. * may be used to specify the text with which to prefix the group field value in the group header line.
  53. * See also {@link #groupRenderer} and
  54. * {@link Ext.grid.GroupingView}.{@link Ext.grid.GroupingView#showGroupName showGroupName}.
  55. */
  56. <div id="cfg-Ext.grid.Column-groupRenderer"></div>/**
  57. * @cfg {Function} groupRenderer <p>Optional. If the grid is being rendered by an {@link Ext.grid.GroupingView}, this option
  58. * may be used to specify the function used to format the grouping field value for display in the group
  59. * {@link #groupName header}. If a <tt><b>groupRenderer</b></tt> is not specified, the configured
  60. * <tt><b>{@link #renderer}</b></tt> will be called; if a <tt><b>{@link #renderer}</b></tt> is also not specified
  61. * the new value of the group field will be used.</p>
  62. * <p>The called function (either the <tt><b>groupRenderer</b></tt> or <tt><b>{@link #renderer}</b></tt>) will be
  63. * passed the following parameters:
  64. * <div class="mdetail-params"><ul>
  65. * <li><b>v</b> : Object<p class="sub-desc">The new value of the group field.</p></li>
  66. * <li><b>unused</b> : undefined<p class="sub-desc">Unused parameter.</p></li>
  67. * <li><b>r</b> : Ext.data.Record<p class="sub-desc">The Record providing the data
  68. * for the row which caused group change.</p></li>
  69. * <li><b>rowIndex</b> : Number<p class="sub-desc">The row index of the Record which caused group change.</p></li>
  70. * <li><b>colIndex</b> : Number<p class="sub-desc">The column index of the group field.</p></li>
  71. * <li><b>ds</b> : Ext.data.Store<p class="sub-desc">The Store which is providing the data Model.</p></li>
  72. * </ul></div></p>
  73. * <p>The function should return a string value.</p>
  74. */
  75. <div id="cfg-Ext.grid.Column-emptyGroupText"></div>/**
  76. * @cfg {String} emptyGroupText Optional. If the grid is being rendered by an {@link Ext.grid.GroupingView}, this option
  77. * may be used to specify the text to display when there is an empty group value. Defaults to the
  78. * {@link Ext.grid.GroupingView}.{@link Ext.grid.GroupingView#emptyGroupText emptyGroupText}.
  79. */
  80. <div id="cfg-Ext.grid.Column-dataIndex"></div>/**
  81. * @cfg {String} dataIndex <p><b>Required</b>. The name of the field in the
  82. * grid's {@link Ext.data.Store}'s {@link Ext.data.Record} definition from
  83. * which to draw the column's value.</p>
  84. */
  85. <div id="cfg-Ext.grid.Column-width"></div>/**
  86. * @cfg {Number} width
  87. * Optional. The initial width in pixels of the column.
  88. * The width of each column can also be affected if any of the following are configured:
  89. * <div class="mdetail-params"><ul>
  90. * <li>{@link Ext.grid.GridPanel}.<tt>{@link Ext.grid.GridPanel#autoExpandColumn autoExpandColumn}</tt></li>
  91. * <li>{@link Ext.grid.GridView}.<tt>{@link Ext.grid.GridView#forceFit forceFit}</tt>
  92. * <div class="sub-desc">
  93. * <p>By specifying <tt>forceFit:true</tt>, {@link #fixed non-fixed width} columns will be
  94. * re-proportioned (based on the relative initial widths) to fill the width of the grid so
  95. * that no horizontal scrollbar is shown.</p>
  96. * </div></li>
  97. * <li>{@link Ext.grid.GridView}.<tt>{@link Ext.grid.GridView#autoFill autoFill}</tt></li>
  98. * <li>{@link Ext.grid.GridPanel}.<tt>{@link Ext.grid.GridPanel#minColumnWidth minColumnWidth}</tt></li>
  99. * <br><p><b>Note</b>: when the width of each column is determined, a space on the right side
  100. * is reserved for the vertical scrollbar. The
  101. * {@link Ext.grid.GridView}.<tt>{@link Ext.grid.GridView#scrollOffset scrollOffset}</tt>
  102. * can be modified to reduce or eliminate the reserved offset.</p>
  103. */
  104. <div id="cfg-Ext.grid.Column-sortable"></div>/**
  105. * @cfg {Boolean} sortable Optional. <tt>true</tt> if sorting is to be allowed on this column.
  106. * Defaults to the value of the <code>{@link Ext.grid.ColumnModel#defaultSortable}</code> property.
  107. * Whether local/remote sorting is used is specified in <code>{@link Ext.data.Store#remoteSort}</code>.
  108. */
  109. <div id="cfg-Ext.grid.Column-fixed"></div>/**
  110. * @cfg {Boolean} fixed Optional. <tt>true</tt> if the column width cannot be changed. Defaults to <tt>false</tt>.
  111. */
  112. <div id="cfg-Ext.grid.Column-resizable"></div>/**
  113. * @cfg {Boolean} resizable Optional. <tt>false</tt> to disable column resizing. Defaults to <tt>true</tt>.
  114. */
  115. <div id="cfg-Ext.grid.Column-menuDisabled"></div>/**
  116. * @cfg {Boolean} menuDisabled Optional. <tt>true</tt> to disable the column menu. Defaults to <tt>false</tt>.
  117. */
  118. <div id="cfg-Ext.grid.Column-hidden"></div>/**
  119. * @cfg {Boolean} hidden
  120. * Optional. <tt>true</tt> to initially hide this column. Defaults to <tt>false</tt>.
  121. * A hidden column {@link Ext.grid.GridPanel#enableColumnHide may be shown via the header row menu}.
  122. * If a column is never to be shown, simply do not include this column in the Column Model at all.
  123. */
  124. <div id="cfg-Ext.grid.Column-tooltip"></div>/**
  125. * @cfg {String} tooltip Optional. A text string to use as the column header's tooltip. If Quicktips
  126. * are enabled, this value will be used as the text of the quick tip, otherwise it will be set as the
  127. * header's HTML title attribute. Defaults to ''.
  128. */
  129. <div id="cfg-Ext.grid.Column-renderer"></div>/**
  130. * @cfg {Mixed} renderer
  131. * <p>For an alternative to specifying a renderer see <code>{@link #xtype}</code></p>
  132. * <p>Optional. A renderer is an 'interceptor' method which can be used transform data (value,
  133. * appearance, etc.) before it is rendered). This may be specified in either of three ways:
  134. * <div class="mdetail-params"><ul>
  135. * <li>A renderer function used to return HTML markup for a cell given the cell's data value.</li>
  136. * <li>A string which references a property name of the {@link Ext.util.Format} class which
  137. * provides a renderer function.</li>
  138. * <li>An object specifying both the renderer function, and its execution scope (<tt><b>this</b></tt>
  139. * reference) e.g.:<pre style="margin-left:1.2em"><code>
  140. {
  141. fn: this.gridRenderer,
  142. scope: this
  143. }
  144. </code></pre></li></ul></div>
  145. * If not specified, the default renderer uses the raw data value.</p>
  146. * <p>For information about the renderer function (passed parameters, etc.), see
  147. * {@link Ext.grid.ColumnModel#setRenderer}. An example of specifying renderer function inline:</p><pre><code>
  148. var companyColumn = {
  149. header: 'Company Name',
  150. dataIndex: 'company',
  151. renderer: function(value, metaData, record, rowIndex, colIndex, store) {
  152. // provide the logic depending on business rules
  153. // name of your own choosing to manipulate the cell depending upon
  154. // the data in the underlying Record object.
  155. if (value == 'whatever') {
  156. //metaData.css : String : A CSS class name to add to the TD element of the cell.
  157. //metaData.attr : String : An html attribute definition string to apply to
  158. // the data container element within the table
  159. // cell (e.g. 'style="color:red;"').
  160. metaData.css = 'name-of-css-class-you-will-define';
  161. }
  162. return value;
  163. }
  164. }
  165. * </code></pre>
  166. * See also {@link #scope}.
  167. */
  168. <div id="cfg-Ext.grid.Column-xtype"></div>/**
  169. * @cfg {String} xtype Optional. A String which references a predefined {@link Ext.grid.Column} subclass
  170. * type which is preconfigured with an appropriate <code>{@link #renderer}</code> to be easily
  171. * configured into a ColumnModel. The predefined {@link Ext.grid.Column} subclass types are:
  172. * <div class="mdetail-params"><ul>
  173. * <li><b><tt>gridcolumn</tt></b> : {@link Ext.grid.Column} (<b>Default</b>)<p class="sub-desc"></p></li>
  174. * <li><b><tt>booleancolumn</tt></b> : {@link Ext.grid.BooleanColumn}<p class="sub-desc"></p></li>
  175. * <li><b><tt>numbercolumn</tt></b> : {@link Ext.grid.NumberColumn}<p class="sub-desc"></p></li>
  176. * <li><b><tt>datecolumn</tt></b> : {@link Ext.grid.DateColumn}<p class="sub-desc"></p></li>
  177. * <li><b><tt>templatecolumn</tt></b> : {@link Ext.grid.TemplateColumn}<p class="sub-desc"></p></li>
  178. * </ul></div>
  179. * <p>Configuration properties for the specified <code>xtype</code> may be specified with
  180. * the Column configuration properties, for example:</p>
  181. * <pre><code>
  182. var grid = new Ext.grid.GridPanel({
  183. ...
  184. columns: [{
  185. header: 'Last Updated',
  186. dataIndex: 'lastChange',
  187. width: 85,
  188. sortable: true,
  189. //renderer: Ext.util.Format.dateRenderer('m/d/Y'),
  190. xtype: 'datecolumn', // use xtype instead of renderer
  191. format: 'M/d/Y' // configuration property for {@link Ext.grid.DateColumn}
  192. }, {
  193. ...
  194. }]
  195. });
  196. * </code></pre>
  197. */
  198. <div id="cfg-Ext.grid.Column-scope"></div>/**
  199. * @cfg {Object} scope Optional. The scope (<tt><b>this</b></tt> reference) in which to execute the
  200. * renderer. Defaults to the Column configuration object.
  201. */
  202. <div id="cfg-Ext.grid.Column-align"></div>/**
  203. * @cfg {String} align Optional. Set the CSS text-align property of the column. Defaults to undefined.
  204. */
  205. <div id="cfg-Ext.grid.Column-css"></div>/**
  206. * @cfg {String} css Optional. An inline style definition string which is applied to all table cells in the column
  207. * (excluding headers). Defaults to undefined.
  208. */
  209. <div id="cfg-Ext.grid.Column-hideable"></div>/**
  210. * @cfg {Boolean} hideable Optional. Specify as <tt>false</tt> to prevent the user from hiding this column
  211. * (defaults to true). To disallow column hiding globally for all columns in the grid, use
  212. * {@link Ext.grid.GridPanel#enableColumnHide} instead.
  213. */
  214. <div id="cfg-Ext.grid.Column-editor"></div>/**
  215. * @cfg {Ext.form.Field} editor Optional. The {@link Ext.form.Field} to use when editing values in this column
  216. * if editing is supported by the grid. See <tt>{@link #editable}</tt> also.
  217. */
  218. /**
  219. * @private
  220. * @cfg {Boolean} isColumn
  221. * Used by ColumnModel setConfig method to avoid reprocessing a Column
  222. * if <code>isColumn</code> is not set ColumnModel will recreate a new Ext.grid.Column
  223. * Defaults to true.
  224. */
  225. isColumn : true,
  226. constructor : function(config){
  227. Ext.apply(this, config);
  228. if(Ext.isString(this.renderer)){
  229. this.renderer = Ext.util.Format[this.renderer];
  230. }else if(Ext.isObject(this.renderer)){
  231. this.scope = this.renderer.scope;
  232. this.renderer = this.renderer.fn;
  233. }
  234. if(!this.scope){
  235. this.scope = this;
  236. }
  237. var ed = this.editor;
  238. delete this.editor;
  239. this.setEditor(ed);
  240. this.addEvents(
  241. <div id="event-Ext.grid.Column-click"></div>/**
  242. * @event click
  243. * Fires when this Column is clicked.
  244. * @param {Column} this
  245. * @param {Grid} The owning GridPanel
  246. * @param {Number} rowIndex
  247. * @param {Ext.EventObject} e
  248. */
  249. 'click',
  250. <div id="event-Ext.grid.Column-contextmenu"></div>/**
  251. * @event contextmenu
  252. * Fires when this Column is right clicked.
  253. * @param {Column} this
  254. * @param {Grid} The owning GridPanel
  255. * @param {Number} rowIndex
  256. * @param {Ext.EventObject} e
  257. */
  258. 'contextmenu',
  259. <div id="event-Ext.grid.Column-dblclick"></div>/**
  260. * @event dblclick
  261. * Fires when this Column is double clicked.
  262. * @param {Column} this
  263. * @param {Grid} The owning GridPanel
  264. * @param {Number} rowIndex
  265. * @param {Ext.EventObject} e
  266. */
  267. 'dblclick',
  268. <div id="event-Ext.grid.Column-mousedown"></div>/**
  269. * @event mousedown
  270. * Fires when this Column receives a mousedown event.
  271. * @param {Column} this
  272. * @param {Grid} The owning GridPanel
  273. * @param {Number} rowIndex
  274. * @param {Ext.EventObject} e
  275. */
  276. 'mousedown'
  277. );
  278. Ext.grid.Column.superclass.constructor.call(this);
  279. },
  280. /**
  281. * @private
  282. * Process and refire events routed from the GridView's processEvent method.
  283. * Returns the event handler's status to allow cancelling of GridView's bubbling process.
  284. */
  285. processEvent : function(name, e, grid, rowIndex, colIndex){
  286. return this.fireEvent(name, this, grid, rowIndex, e);
  287. },
  288. /**
  289. * @private
  290. * Clean up. Remove any Editor. Remove any listeners.
  291. */
  292. destroy: function() {
  293. if(this.setEditor){
  294. this.setEditor(null);
  295. }
  296. this.purgeListeners();
  297. },
  298. <div id="prop-Ext.grid.Column-renderer"></div>/**
  299. * Optional. A function which returns displayable data when passed the following parameters:
  300. * <div class="mdetail-params"><ul>
  301. * <li><b>value</b> : Object<p class="sub-desc">The data value for the cell.</p></li>
  302. * <li><b>metadata</b> : Object<p class="sub-desc">An object in which you may set the following attributes:<ul>
  303. * <li><b>css</b> : String<p class="sub-desc">A CSS class name to add to the cell's TD element.</p></li>
  304. * <li><b>attr</b> : String<p class="sub-desc">An HTML attribute definition string to apply to the data container
  305. * element <i>within</i> the table cell (e.g. 'style="color:red;"').</p></li></ul></p></li>
  306. * <li><b>record</b> : Ext.data.record<p class="sub-desc">The {@link Ext.data.Record} from which the data was
  307. * extracted.</p></li>
  308. * <li><b>rowIndex</b> : Number<p class="sub-desc">Row index</p></li>
  309. * <li><b>colIndex</b> : Number<p class="sub-desc">Column index</p></li>
  310. * <li><b>store</b> : Ext.data.Store<p class="sub-desc">The {@link Ext.data.Store} object from which the Record
  311. * was extracted.</p></li>
  312. * </ul></div>
  313. * @property renderer
  314. * @type Function
  315. */
  316. renderer : function(value){
  317. return value;
  318. },
  319. // private
  320. getEditor: function(rowIndex){
  321. return this.editable !== false ? this.editor : null;
  322. },
  323. <div id="method-Ext.grid.Column-setEditor"></div>/**
  324. * Sets a new editor for this column.
  325. * @param {Ext.Editor/Ext.form.Field} editor The editor to set
  326. */
  327. setEditor : function(editor){
  328. var ed = this.editor;
  329. if(ed){
  330. if(ed.gridEditor){
  331. ed.gridEditor.destroy();
  332. delete ed.gridEditor;
  333. }else{
  334. ed.destroy();
  335. }
  336. }
  337. this.editor = null;
  338. if(editor){
  339. //not an instance, create it
  340. if(!editor.isXType){
  341. editor = Ext.create(editor, 'textfield');
  342. }
  343. this.editor = editor;
  344. }
  345. },
  346. <div id="method-Ext.grid.Column-getCellEditor"></div>/**
  347. * Returns the {@link Ext.Editor editor} defined for this column that was created to wrap the {@link Ext.form.Field Field}
  348. * used to edit the cell.
  349. * @param {Number} rowIndex The row index
  350. * @return {Ext.Editor}
  351. */
  352. getCellEditor: function(rowIndex){
  353. var ed = this.getEditor(rowIndex);
  354. if(ed){
  355. if(!ed.startEdit){
  356. if(!ed.gridEditor){
  357. ed.gridEditor = new Ext.grid.GridEditor(ed);
  358. }
  359. ed = ed.gridEditor;
  360. }
  361. }
  362. return ed;
  363. }
  364. });
  365. <div id="cls-Ext.grid.BooleanColumn"></div>/**
  366. * @class Ext.grid.BooleanColumn
  367. * @extends Ext.grid.Column
  368. * <p>A Column definition class which renders boolean data fields. See the {@link Ext.grid.Column#xtype xtype}
  369. * config option of {@link Ext.grid.Column} for more details.</p>
  370. */
  371. Ext.grid.BooleanColumn = Ext.extend(Ext.grid.Column, {
  372. <div id="cfg-Ext.grid.BooleanColumn-trueText"></div>/**
  373. * @cfg {String} trueText
  374. * The string returned by the renderer when the column value is not falsy (defaults to <tt>'true'</tt>).
  375. */
  376. trueText: 'true',
  377. <div id="cfg-Ext.grid.BooleanColumn-falseText"></div>/**
  378. * @cfg {String} falseText
  379. * The string returned by the renderer when the column value is falsy (but not undefined) (defaults to
  380. * <tt>'false'</tt>).
  381. */
  382. falseText: 'false',
  383. <div id="cfg-Ext.grid.BooleanColumn-undefinedText"></div>/**
  384. * @cfg {String} undefinedText
  385. * The string returned by the renderer when the column value is undefined (defaults to <tt>'&amp;#160;'</tt>).
  386. */
  387. undefinedText: '&#160;',
  388. constructor: function(cfg){
  389. Ext.grid.BooleanColumn.superclass.constructor.call(this, cfg);
  390. var t = this.trueText, f = this.falseText, u = this.undefinedText;
  391. this.renderer = function(v){
  392. if(v === undefined){
  393. return u;
  394. }
  395. if(!v || v === 'false'){
  396. return f;
  397. }
  398. return t;
  399. };
  400. }
  401. });
  402. <div id="cls-Ext.grid.NumberColumn"></div>/**
  403. * @class Ext.grid.NumberColumn
  404. * @extends Ext.grid.Column
  405. * <p>A Column definition class which renders a numeric data field according to a {@link #format} string. See the
  406. * {@link Ext.grid.Column#xtype xtype} config option of {@link Ext.grid.Column} for more details.</p>
  407. */
  408. Ext.grid.NumberColumn = Ext.extend(Ext.grid.Column, {
  409. <div id="cfg-Ext.grid.NumberColumn-format"></div>/**
  410. * @cfg {String} format
  411. * A formatting string as used by {@link Ext.util.Format#number} to format a numeric value for this Column
  412. * (defaults to <tt>'0,000.00'</tt>).
  413. */
  414. format : '0,000.00',
  415. constructor: function(cfg){
  416. Ext.grid.NumberColumn.superclass.constructor.call(this, cfg);
  417. this.renderer = Ext.util.Format.numberRenderer(this.format);
  418. }
  419. });
  420. <div id="cls-Ext.grid.DateColumn"></div>/**
  421. * @class Ext.grid.DateColumn
  422. * @extends Ext.grid.Column
  423. * <p>A Column definition class which renders a passed date according to the default locale, or a configured
  424. * {@link #format}. See the {@link Ext.grid.Column#xtype xtype} config option of {@link Ext.grid.Column}
  425. * for more details.</p>
  426. */
  427. Ext.grid.DateColumn = Ext.extend(Ext.grid.Column, {
  428. <div id="cfg-Ext.grid.DateColumn-format"></div>/**
  429. * @cfg {String} format
  430. * A formatting string as used by {@link Date#format} to format a Date for this Column
  431. * (defaults to <tt>'m/d/Y'</tt>).
  432. */
  433. format : 'm/d/Y',
  434. constructor: function(cfg){
  435. Ext.grid.DateColumn.superclass.constructor.call(this, cfg);
  436. this.renderer = Ext.util.Format.dateRenderer(this.format);
  437. }
  438. });
  439. <div id="cls-Ext.grid.TemplateColumn"></div>/**
  440. * @class Ext.grid.TemplateColumn
  441. * @extends Ext.grid.Column
  442. * <p>A Column definition class which renders a value by processing a {@link Ext.data.Record Record}'s
  443. * {@link Ext.data.Record#data data} using a {@link #tpl configured} {@link Ext.XTemplate XTemplate}.
  444. * See the {@link Ext.grid.Column#xtype xtype} config option of {@link Ext.grid.Column} for more
  445. * details.</p>
  446. */
  447. Ext.grid.TemplateColumn = Ext.extend(Ext.grid.Column, {
  448. <div id="cfg-Ext.grid.TemplateColumn-tpl"></div>/**
  449. * @cfg {String/XTemplate} tpl
  450. * An {@link Ext.XTemplate XTemplate}, or an XTemplate <i>definition string</i> to use to process a
  451. * {@link Ext.data.Record Record}'s {@link Ext.data.Record#data data} to produce a column's rendered value.
  452. */
  453. constructor: function(cfg){
  454. Ext.grid.TemplateColumn.superclass.constructor.call(this, cfg);
  455. var tpl = (!Ext.isPrimitive(this.tpl) && this.tpl.compile) ? this.tpl : new Ext.XTemplate(this.tpl);
  456. this.renderer = function(value, p, r){
  457. return tpl.apply(r.data);
  458. };
  459. this.tpl = tpl;
  460. }
  461. });
  462. <div id="cls-Ext.grid.ActionColumn"></div>/**
  463. * @class Ext.grid.ActionColumn
  464. * @extends Ext.grid.Column
  465. * <p>A Grid column type which renders an icon, or a series of icons in a grid cell, and offers a scoped click
  466. * handler for each icon. Example usage:</p>
  467. <pre><code>
  468. new Ext.grid.GridPanel({
  469. store: myStore,
  470. columns: [
  471. {
  472. xtype: 'actioncolumn',
  473. width: 50,
  474. items: [
  475. {
  476. icon : 'sell.gif', // Use a URL in the icon config
  477. tooltip: 'Sell stock',
  478. handler: function(grid, rowIndex, colIndex) {
  479. var rec = store.getAt(rowIndex);
  480. alert("Sell " + rec.get('company'));
  481. }
  482. },
  483. {
  484. getClass: function(v, meta, rec) { // Or return a class from a function
  485. if (rec.get('change') < 0) {
  486. this.items[1].tooltip = 'Do not buy!';
  487. return 'alert-col';
  488. } else {
  489. this.items[1].tooltip = 'Buy stock';
  490. return 'buy-col';
  491. }
  492. },
  493. handler: function(grid, rowIndex, colIndex) {
  494. var rec = store.getAt(rowIndex);
  495. alert("Buy " + rec.get('company'));
  496. }
  497. }
  498. ]
  499. }
  500. //any other columns here
  501. ]
  502. });
  503. </pre></code>
  504. * <p>The action column can be at any index in the columns array, and a grid can have any number of
  505. * action columns. </p>
  506. */
  507. Ext.grid.ActionColumn = Ext.extend(Ext.grid.Column, {
  508. <div id="cfg-Ext.grid.ActionColumn-icon"></div>/**
  509. * @cfg {String} icon
  510. * The URL of an image to display as the clickable element in the column.
  511. * Optional - defaults to <code>{@link Ext#BLANK_IMAGE_URL Ext.BLANK_IMAGE_URL}</code>.
  512. */
  513. <div id="cfg-Ext.grid.ActionColumn-iconCls"></div>/**
  514. * @cfg {String} iconCls
  515. * A CSS class to apply to the icon image. To determine the class dynamically, configure the Column with a <code>{@link #getClass}</code> function.
  516. */
  517. <div id="cfg-Ext.grid.ActionColumn-handler"></div>/**
  518. * @cfg {Function} handler A function called when the icon is clicked.
  519. * The handler is passed the following parameters:<div class="mdetail-params"><ul>
  520. * <li><code>grid</code> : GridPanel<div class="sub-desc">The owning GridPanel.</div></li>
  521. * <li><code>rowIndex</code> : Number<div class="sub-desc">The row index clicked on.</div></li>
  522. * <li><code>colIndex</code> : Number<div class="sub-desc">The column index clicked on.</div></li>
  523. * <li><code>item</code> : Object<div class="sub-desc">The clicked item (or this Column if multiple
  524. * {@link #items} were not configured).</div></li>
  525. * <li><code>e</code> : Event<div class="sub-desc">The click event.</div></li>
  526. * </ul></div>
  527. */
  528. <div id="cfg-Ext.grid.ActionColumn-scope"></div>/**
  529. * @cfg {Object} scope The scope (<tt><b>this</b></tt> reference) in which the <code>{@link #handler}</code>
  530. * and <code>{@link #getClass}</code> fuctions are executed. Defaults to this Column.
  531. */
  532. <div id="cfg-Ext.grid.ActionColumn-tooltip"></div>/**
  533. * @cfg {String} tooltip A tooltip message to be displayed on hover. {@link Ext.QuickTips#init Ext.QuickTips} must have
  534. * been initialized.
  535. */
  536. <div id="cfg-Ext.grid.ActionColumn-stopSelection"></div>/**
  537. * @cfg {Boolean} stopSelection Defaults to <code>true</code>. Prevent grid <i>row</i> selection upon mousedown.
  538. */
  539. <div id="cfg-Ext.grid.ActionColumn-getClass"></div>/**
  540. * @cfg {Function} getClass A function which returns the CSS class to apply to the icon image.
  541. * The function is passed the following parameters:<div class="mdetail-params"><ul>
  542. * <li><b>v</b> : Object<p class="sub-desc">The value of the column's configured field (if any).</p></li>
  543. * <li><b>metadata</b> : Object<p class="sub-desc">An object in which you may set the following attributes:<ul>
  544. * <li><b>css</b> : String<p class="sub-desc">A CSS class name to add to the cell's TD element.</p></li>
  545. * <li><b>attr</b> : String<p class="sub-desc">An HTML attribute definition string to apply to the data container element <i>within</i> the table cell
  546. * (e.g. 'style="color:red;"').</p></li>
  547. * </ul></p></li>
  548. * <li><b>r</b> : Ext.data.Record<p class="sub-desc">The Record providing the data.</p></li>
  549. * <li><b>rowIndex</b> : Number<p class="sub-desc">The row index..</p></li>
  550. * <li><b>colIndex</b> : Number<p class="sub-desc">The column index.</p></li>
  551. * <li><b>store</b> : Ext.data.Store<p class="sub-desc">The Store which is providing the data Model.</p></li>
  552. * </ul></div>
  553. */
  554. <div id="cfg-Ext.grid.ActionColumn-items"></div>/**
  555. * @cfg {Array} items An Array which may contain multiple icon definitions, each element of which may contain:
  556. * <div class="mdetail-params"><ul>
  557. * <li><code>icon</code> : String<div class="sub-desc">The url of an image to display as the clickable element
  558. * in the column.</div></li>
  559. * <li><code>iconCls</code> : String<div class="sub-desc">A CSS class to apply to the icon image.
  560. * To determine the class dynamically, configure the item with a <code>getClass</code> function.</div></li>
  561. * <li><code>getClass</code> : Function<div class="sub-desc">A function which returns the CSS class to apply to the icon image.
  562. * The function is passed the following parameters:<ul>
  563. * <li><b>v</b> : Object<p class="sub-desc">The value of the column's configured field (if any).</p></li>
  564. * <li><b>metadata</b> : Object<p class="sub-desc">An object in which you may set the following attributes:<ul>
  565. * <li><b>css</b> : String<p class="sub-desc">A CSS class name to add to the cell's TD element.</p></li>
  566. * <li><b>attr</b> : String<p class="sub-desc">An HTML attribute definition string to apply to the data container element <i>within</i> the table cell
  567. * (e.g. 'style="color:red;"').</p></li>
  568. * </ul></p></li>
  569. * <li><b>r</b> : Ext.data.Record<p class="sub-desc">The Record providing the data.</p></li>
  570. * <li><b>rowIndex</b> : Number<p class="sub-desc">The row index..</p></li>
  571. * <li><b>colIndex</b> : Number<p class="sub-desc">The column index.</p></li>
  572. * <li><b>store</b> : Ext.data.Store<p class="sub-desc">The Store which is providing the data Model.</p></li>
  573. * </ul></div></li>
  574. * <li><code>handler</code> : Function<div class="sub-desc">A function called when the icon is clicked.</div></li>
  575. * <li><code>scope</code> : Scope<div class="sub-desc">The scope (<code><b>this</b></code> reference) in which the
  576. * <code>handler</code> and <code>getClass</code> functions are executed. Fallback defaults are this Column's
  577. * configured scope, then this Column.</div></li>
  578. * <li><code>tooltip</code> : String<div class="sub-desc">A tooltip message to be displayed on hover.
  579. * {@link Ext.QuickTips#init Ext.QuickTips} must have been initialized.</div></li>
  580. * </ul></div>
  581. */
  582. header: '&#160;',
  583. actionIdRe: /x-action-col-(\d+)/,
  584. <div id="cfg-Ext.grid.ActionColumn-altText"></div>/**
  585. * @cfg {String} altText The alt text to use for the image element. Defaults to <tt>''</tt>.
  586. */
  587. altText: '',
  588. constructor: function(cfg) {
  589. var me = this,
  590. items = cfg.items || (me.items = [me]),
  591. l = items.length,
  592. i,
  593. item;
  594. Ext.grid.ActionColumn.superclass.constructor.call(me, cfg);
  595. // Renderer closure iterates through items creating an <img> element for each and tagging with an identifying
  596. // class name x-action-col-{n}
  597. me.renderer = function(v, meta) {
  598. // Allow a configured renderer to create initial value (And set the other values in the "metadata" argument!)
  599. v = Ext.isFunction(cfg.renderer) ? cfg.renderer.apply(this, arguments)||'' : '';
  600. meta.css += ' x-action-col-cell';
  601. for (i = 0; i < l; i++) {
  602. item = items[i];
  603. v += '<img alt="' + me.altText + '" src="' + (item.icon || Ext.BLANK_IMAGE_URL) +
  604. '" class="x-action-col-icon x-action-col-' + String(i) + ' ' + (item.iconCls || '') +
  605. ' ' + (Ext.isFunction(item.getClass) ? item.getClass.apply(item.scope||this.scope||this, arguments) : '') + '"' +
  606. ((item.tooltip) ? ' ext:qtip="' + item.tooltip + '"' : '') + ' />';
  607. }
  608. return v;
  609. };
  610. },
  611. destroy: function() {
  612. delete this.items;
  613. delete this.renderer;
  614. return Ext.grid.ActionColumn.superclass.destroy.apply(this, arguments);
  615. },
  616. /**
  617. * @private
  618. * Process and refire events routed from the GridView's processEvent method.
  619. * Also fires any configured click handlers. By default, cancels the mousedown event to prevent selection.
  620. * Returns the event handler's status to allow cancelling of GridView's bubbling process.
  621. */
  622. processEvent : function(name, e, grid, rowIndex, colIndex){
  623. var m = e.getTarget().className.match(this.actionIdRe),
  624. item, fn;
  625. if (m && (item = this.items[parseInt(m[1], 10)])) {
  626. if (name == 'click') {
  627. (fn = item.handler || this.handler) && fn.call(item.scope||this.scope||this, grid, rowIndex, colIndex, item, e);
  628. } else if ((name == 'mousedown') && (item.stopSelection !== false)) {
  629. return false;
  630. }
  631. }
  632. return Ext.grid.ActionColumn.superclass.processEvent.apply(this, arguments);
  633. }
  634. });
  635. /*
  636. * @property types
  637. * @type Object
  638. * @member Ext.grid.Column
  639. * @static
  640. * <p>An object containing predefined Column classes keyed by a mnemonic code which may be referenced
  641. * by the {@link Ext.grid.ColumnModel#xtype xtype} config option of ColumnModel.</p>
  642. * <p>This contains the following properties</p><div class="mdesc-details"><ul>
  643. * <li>gridcolumn : <b>{@link Ext.grid.Column Column constructor}</b></li>
  644. * <li>booleancolumn : <b>{@link Ext.grid.BooleanColumn BooleanColumn constructor}</b></li>
  645. * <li>numbercolumn : <b>{@link Ext.grid.NumberColumn NumberColumn constructor}</b></li>
  646. * <li>datecolumn : <b>{@link Ext.grid.DateColumn DateColumn constructor}</b></li>
  647. * <li>templatecolumn : <b>{@link Ext.grid.TemplateColumn TemplateColumn constructor}</b></li>
  648. * </ul></div>
  649. */
  650. Ext.grid.Column.types = {
  651. gridcolumn : Ext.grid.Column,
  652. booleancolumn: Ext.grid.BooleanColumn,
  653. numbercolumn: Ext.grid.NumberColumn,
  654. datecolumn: Ext.grid.DateColumn,
  655. templatecolumn: Ext.grid.TemplateColumn,
  656. actioncolumn: Ext.grid.ActionColumn
  657. };</pre>
  658. </body>
  659. </html>