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.

608 lines
22 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. /**
  8. * @class Ext.grid.GroupingView
  9. * @extends Ext.grid.GridView
  10. * Adds the ability for single level grouping to the grid. A {@link Ext.data.GroupingStore GroupingStore}
  11. * must be used to enable grouping. Some grouping characteristics may also be configured at the
  12. * {@link Ext.grid.Column Column level}<div class="mdetail-params"><ul>
  13. * <li><code>{@link Ext.grid.Column#emptyGroupText emptyGroupText}</code></li>
  14. * <li><code>{@link Ext.grid.Column#groupable groupable}</code></li>
  15. * <li><code>{@link Ext.grid.Column#groupName groupName}</code></li>
  16. * <li><code>{@link Ext.grid.Column#groupRender groupRender}</code></li>
  17. * </ul></div>
  18. * <p>Sample usage:</p>
  19. * <pre><code>
  20. var grid = new Ext.grid.GridPanel({
  21. // A groupingStore is required for a GroupingView
  22. store: new {@link Ext.data.GroupingStore}({
  23. autoDestroy: true,
  24. reader: reader,
  25. data: xg.dummyData,
  26. sortInfo: {field: 'company', direction: 'ASC'},
  27. {@link Ext.data.GroupingStore#groupOnSort groupOnSort}: true,
  28. {@link Ext.data.GroupingStore#remoteGroup remoteGroup}: true,
  29. {@link Ext.data.GroupingStore#groupField groupField}: 'industry'
  30. }),
  31. colModel: new {@link Ext.grid.ColumnModel}({
  32. columns:[
  33. {id:'company',header: 'Company', width: 60, dataIndex: 'company'},
  34. // {@link Ext.grid.Column#groupable groupable}, {@link Ext.grid.Column#groupName groupName}, {@link Ext.grid.Column#groupRender groupRender} are also configurable at column level
  35. {header: 'Price', renderer: Ext.util.Format.usMoney, dataIndex: 'price', {@link Ext.grid.Column#groupable groupable}: false},
  36. {header: 'Change', dataIndex: 'change', renderer: Ext.util.Format.usMoney},
  37. {header: 'Industry', dataIndex: 'industry'},
  38. {header: 'Last Updated', renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
  39. ],
  40. defaults: {
  41. sortable: true,
  42. menuDisabled: false,
  43. width: 20
  44. }
  45. }),
  46. view: new Ext.grid.GroupingView({
  47. {@link Ext.grid.GridView#forceFit forceFit}: true,
  48. // custom grouping text template to display the number of items per group
  49. {@link #groupTextTpl}: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'
  50. }),
  51. frame:true,
  52. width: 700,
  53. height: 450,
  54. collapsible: true,
  55. animCollapse: false,
  56. title: 'Grouping Example',
  57. iconCls: 'icon-grid',
  58. renderTo: document.body
  59. });
  60. * </code></pre>
  61. * @constructor
  62. * @param {Object} config
  63. */
  64. Ext.grid.GroupingView = Ext.extend(Ext.grid.GridView, {
  65. /**
  66. * @cfg {String} groupByText Text displayed in the grid header menu for grouping by a column
  67. * (defaults to 'Group By This Field').
  68. */
  69. groupByText : 'Group By This Field',
  70. /**
  71. * @cfg {String} showGroupsText Text displayed in the grid header for enabling/disabling grouping
  72. * (defaults to 'Show in Groups').
  73. */
  74. showGroupsText : 'Show in Groups',
  75. /**
  76. * @cfg {Boolean} hideGroupedColumn <tt>true</tt> to hide the column that is currently grouped (defaults to <tt>false</tt>)
  77. */
  78. hideGroupedColumn : false,
  79. /**
  80. * @cfg {Boolean} showGroupName If <tt>true</tt> will display a prefix plus a ': ' before the group field value
  81. * in the group header line. The prefix will consist of the <tt><b>{@link Ext.grid.Column#groupName groupName}</b></tt>
  82. * (or the configured <tt><b>{@link Ext.grid.Column#header header}</b></tt> if not provided) configured in the
  83. * {@link Ext.grid.Column} for each set of grouped rows (defaults to <tt>true</tt>).
  84. */
  85. showGroupName : true,
  86. /**
  87. * @cfg {Boolean} startCollapsed <tt>true</tt> to start all groups collapsed (defaults to <tt>false</tt>)
  88. */
  89. startCollapsed : false,
  90. /**
  91. * @cfg {Boolean} enableGrouping <tt>false</tt> to disable grouping functionality (defaults to <tt>true</tt>)
  92. */
  93. enableGrouping : true,
  94. /**
  95. * @cfg {Boolean} enableGroupingMenu <tt>true</tt> to enable the grouping control in the column menu (defaults to <tt>true</tt>)
  96. */
  97. enableGroupingMenu : true,
  98. /**
  99. * @cfg {Boolean} enableNoGroups <tt>true</tt> to allow the user to turn off grouping (defaults to <tt>true</tt>)
  100. */
  101. enableNoGroups : true,
  102. /**
  103. * @cfg {String} emptyGroupText The text to display when there is an empty group value (defaults to <tt>'(None)'</tt>).
  104. * May also be specified per column, see {@link Ext.grid.Column}.{@link Ext.grid.Column#emptyGroupText emptyGroupText}.
  105. */
  106. emptyGroupText : '(None)',
  107. /**
  108. * @cfg {Boolean} ignoreAdd <tt>true</tt> to skip refreshing the view when new rows are added (defaults to <tt>false</tt>)
  109. */
  110. ignoreAdd : false,
  111. /**
  112. * @cfg {String} groupTextTpl The template used to render the group header (defaults to <tt>'{text}'</tt>).
  113. * This is used to format an object which contains the following properties:
  114. * <div class="mdetail-params"><ul>
  115. * <li><b>group</b> : String<p class="sub-desc">The <i>rendered</i> value of the group field.
  116. * By default this is the unchanged value of the group field. If a <tt><b>{@link Ext.grid.Column#groupRenderer groupRenderer}</b></tt>
  117. * is specified, it is the result of a call to that function.</p></li>
  118. * <li><b>gvalue</b> : Object<p class="sub-desc">The <i>raw</i> value of the group field.</p></li>
  119. * <li><b>text</b> : String<p class="sub-desc">The configured header (as described in <tt>{@link #showGroupName})</tt>
  120. * if <tt>{@link #showGroupName}</tt> is <tt>true</tt>) plus the <i>rendered</i> group field value.</p></li>
  121. * <li><b>groupId</b> : String<p class="sub-desc">A unique, generated ID which is applied to the
  122. * View Element which contains the group.</p></li>
  123. * <li><b>startRow</b> : Number<p class="sub-desc">The row index of the Record which caused group change.</p></li>
  124. * <li><b>rs</b> : Array<p class="sub-desc">Contains a single element: The Record providing the data
  125. * for the row which caused group change.</p></li>
  126. * <li><b>cls</b> : String<p class="sub-desc">The generated class name string to apply to the group header Element.</p></li>
  127. * <li><b>style</b> : String<p class="sub-desc">The inline style rules to apply to the group header Element.</p></li>
  128. * </ul></div></p>
  129. * See {@link Ext.XTemplate} for information on how to format data using a template. Possible usage:<pre><code>
  130. var grid = new Ext.grid.GridPanel({
  131. ...
  132. view: new Ext.grid.GroupingView({
  133. groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'
  134. }),
  135. });
  136. * </code></pre>
  137. */
  138. groupTextTpl : '{text}',
  139. /**
  140. * @cfg {String} groupMode Indicates how to construct the group identifier. <tt>'value'</tt> constructs the id using
  141. * raw value, <tt>'display'</tt> constructs the id using the rendered value. Defaults to <tt>'value'</tt>.
  142. */
  143. groupMode: 'value',
  144. /**
  145. * @cfg {Function} groupRenderer This property must be configured in the {@link Ext.grid.Column} for
  146. * each column.
  147. */
  148. /**
  149. * @cfg {Boolean} cancelEditOnToggle True to cancel any editing when the group header is toggled. Defaults to <tt>true</tt>.
  150. */
  151. cancelEditOnToggle: true,
  152. // private
  153. initTemplates : function(){
  154. Ext.grid.GroupingView.superclass.initTemplates.call(this);
  155. this.state = {};
  156. var sm = this.grid.getSelectionModel();
  157. sm.on(sm.selectRow ? 'beforerowselect' : 'beforecellselect',
  158. this.onBeforeRowSelect, this);
  159. if(!this.startGroup){
  160. this.startGroup = new Ext.XTemplate(
  161. '<div id="{groupId}" class="x-grid-group {cls}">',
  162. '<div id="{groupId}-hd" class="x-grid-group-hd" style="{style}"><div class="x-grid-group-title">', this.groupTextTpl ,'</div></div>',
  163. '<div id="{groupId}-bd" class="x-grid-group-body">'
  164. );
  165. }
  166. this.startGroup.compile();
  167. if (!this.endGroup) {
  168. this.endGroup = '</div></div>';
  169. }
  170. },
  171. // private
  172. findGroup : function(el){
  173. return Ext.fly(el).up('.x-grid-group', this.mainBody.dom);
  174. },
  175. // private
  176. getGroups : function(){
  177. return this.hasRows() ? this.mainBody.dom.childNodes : [];
  178. },
  179. // private
  180. onAdd : function(ds, records, index) {
  181. if (this.canGroup() && !this.ignoreAdd) {
  182. var ss = this.getScrollState();
  183. this.fireEvent('beforerowsinserted', ds, index, index + (records.length-1));
  184. this.refresh();
  185. this.restoreScroll(ss);
  186. this.fireEvent('rowsinserted', ds, index, index + (records.length-1));
  187. } else if (!this.canGroup()) {
  188. Ext.grid.GroupingView.superclass.onAdd.apply(this, arguments);
  189. }
  190. },
  191. // private
  192. onRemove : function(ds, record, index, isUpdate){
  193. Ext.grid.GroupingView.superclass.onRemove.apply(this, arguments);
  194. var g = document.getElementById(record._groupId);
  195. if(g && g.childNodes[1].childNodes.length < 1){
  196. Ext.removeNode(g);
  197. }
  198. this.applyEmptyText();
  199. },
  200. // private
  201. refreshRow : function(record){
  202. if(this.ds.getCount()==1){
  203. this.refresh();
  204. }else{
  205. this.isUpdating = true;
  206. Ext.grid.GroupingView.superclass.refreshRow.apply(this, arguments);
  207. this.isUpdating = false;
  208. }
  209. },
  210. // private
  211. beforeMenuShow : function(){
  212. var item, items = this.hmenu.items, disabled = this.cm.config[this.hdCtxIndex].groupable === false;
  213. if((item = items.get('groupBy'))){
  214. item.setDisabled(disabled);
  215. }
  216. if((item = items.get('showGroups'))){
  217. item.setDisabled(disabled);
  218. item.setChecked(this.canGroup(), true);
  219. }
  220. },
  221. // private
  222. renderUI : function(){
  223. var markup = Ext.grid.GroupingView.superclass.renderUI.call(this);
  224. if(this.enableGroupingMenu && this.hmenu){
  225. this.hmenu.add('-',{
  226. itemId:'groupBy',
  227. text: this.groupByText,
  228. handler: this.onGroupByClick,
  229. scope: this,
  230. iconCls:'x-group-by-icon'
  231. });
  232. if(this.enableNoGroups){
  233. this.hmenu.add({
  234. itemId:'showGroups',
  235. text: this.showGroupsText,
  236. checked: true,
  237. checkHandler: this.onShowGroupsClick,
  238. scope: this
  239. });
  240. }
  241. this.hmenu.on('beforeshow', this.beforeMenuShow, this);
  242. }
  243. return markup;
  244. },
  245. processEvent: function(name, e){
  246. Ext.grid.GroupingView.superclass.processEvent.call(this, name, e);
  247. var hd = e.getTarget('.x-grid-group-hd', this.mainBody);
  248. if(hd){
  249. // group value is at the end of the string
  250. var field = this.getGroupField(),
  251. prefix = this.getPrefix(field),
  252. groupValue = hd.id.substring(prefix.length),
  253. emptyRe = new RegExp('gp-' + Ext.escapeRe(field) + '--hd');
  254. // remove trailing '-hd'
  255. groupValue = groupValue.substr(0, groupValue.length - 3);
  256. // also need to check for empty groups
  257. if(groupValue || emptyRe.test(hd.id)){
  258. this.grid.fireEvent('group' + name, this.grid, field, groupValue, e);
  259. }
  260. if(name == 'mousedown' && e.button == 0){
  261. this.toggleGroup(hd.parentNode);
  262. }
  263. }
  264. },
  265. // private
  266. onGroupByClick : function(){
  267. var grid = this.grid;
  268. this.enableGrouping = true;
  269. grid.store.groupBy(this.cm.getDataIndex(this.hdCtxIndex));
  270. grid.fireEvent('groupchange', grid, grid.store.getGroupState());
  271. this.beforeMenuShow(); // Make sure the checkboxes get properly set when changing groups
  272. this.refresh();
  273. },
  274. // private
  275. onShowGroupsClick : function(mi, checked){
  276. this.enableGrouping = checked;
  277. if(checked){
  278. this.onGroupByClick();
  279. }else{
  280. this.grid.store.clearGrouping();
  281. this.grid.fireEvent('groupchange', this, null);
  282. }
  283. },
  284. /**
  285. * Toggle the group that contains the specific row.
  286. * @param {Number} rowIndex The row inside the group
  287. * @param {Boolean} expanded (optional)
  288. */
  289. toggleRowIndex : function(rowIndex, expanded){
  290. if(!this.canGroup()){
  291. return;
  292. }
  293. var row = this.getRow(rowIndex);
  294. if(row){
  295. this.toggleGroup(this.findGroup(row), expanded);
  296. }
  297. },
  298. /**
  299. * Toggles the specified group if no value is passed, otherwise sets the expanded state of the group to the value passed.
  300. * @param {String} groupId The groupId assigned to the group (see getGroupId)
  301. * @param {Boolean} expanded (optional)
  302. */
  303. toggleGroup : function(group, expanded){
  304. var gel = Ext.get(group);
  305. expanded = Ext.isDefined(expanded) ? expanded : gel.hasClass('x-grid-group-collapsed');
  306. if(this.state[gel.id] !== expanded){
  307. if (this.cancelEditOnToggle !== false) {
  308. this.grid.stopEditing(true);
  309. }
  310. this.state[gel.id] = expanded;
  311. gel[expanded ? 'removeClass' : 'addClass']('x-grid-group-collapsed');
  312. }
  313. },
  314. /**
  315. * Toggles all groups if no value is passed, otherwise sets the expanded state of all groups to the value passed.
  316. * @param {Boolean} expanded (optional)
  317. */
  318. toggleAllGroups : function(expanded){
  319. var groups = this.getGroups();
  320. for(var i = 0, len = groups.length; i < len; i++){
  321. this.toggleGroup(groups[i], expanded);
  322. }
  323. },
  324. /**
  325. * Expands all grouped rows.
  326. */
  327. expandAllGroups : function(){
  328. this.toggleAllGroups(true);
  329. },
  330. /**
  331. * Collapses all grouped rows.
  332. */
  333. collapseAllGroups : function(){
  334. this.toggleAllGroups(false);
  335. },
  336. // private
  337. getGroup : function(v, r, groupRenderer, rowIndex, colIndex, ds){
  338. var column = this.cm.config[colIndex],
  339. g = groupRenderer ? groupRenderer.call(column.scope, v, {}, r, rowIndex, colIndex, ds) : String(v);
  340. if(g === '' || g === '&#160;'){
  341. g = column.emptyGroupText || this.emptyGroupText;
  342. }
  343. return g;
  344. },
  345. // private
  346. getGroupField : function(){
  347. return this.grid.store.getGroupState();
  348. },
  349. // private
  350. afterRender : function(){
  351. if(!this.ds || !this.cm){
  352. return;
  353. }
  354. Ext.grid.GroupingView.superclass.afterRender.call(this);
  355. if(this.grid.deferRowRender){
  356. this.updateGroupWidths();
  357. }
  358. },
  359. afterRenderUI: function () {
  360. Ext.grid.GroupingView.superclass.afterRenderUI.call(this);
  361. if (this.enableGroupingMenu && this.hmenu) {
  362. this.hmenu.add('-',{
  363. itemId:'groupBy',
  364. text: this.groupByText,
  365. handler: this.onGroupByClick,
  366. scope: this,
  367. iconCls:'x-group-by-icon'
  368. });
  369. if (this.enableNoGroups) {
  370. this.hmenu.add({
  371. itemId:'showGroups',
  372. text: this.showGroupsText,
  373. checked: true,
  374. checkHandler: this.onShowGroupsClick,
  375. scope: this
  376. });
  377. }
  378. this.hmenu.on('beforeshow', this.beforeMenuShow, this);
  379. }
  380. },
  381. // private
  382. renderRows : function(){
  383. var groupField = this.getGroupField();
  384. var eg = !!groupField;
  385. // if they turned off grouping and the last grouped field is hidden
  386. if(this.hideGroupedColumn) {
  387. var colIndex = this.cm.findColumnIndex(groupField),
  388. hasLastGroupField = Ext.isDefined(this.lastGroupField);
  389. if(!eg && hasLastGroupField){
  390. this.mainBody.update('');
  391. this.cm.setHidden(this.cm.findColumnIndex(this.lastGroupField), false);
  392. delete this.lastGroupField;
  393. }else if (eg && !hasLastGroupField){
  394. this.lastGroupField = groupField;
  395. this.cm.setHidden(colIndex, true);
  396. }else if (eg && hasLastGroupField && groupField !== this.lastGroupField) {
  397. this.mainBody.update('');
  398. var oldIndex = this.cm.findColumnIndex(this.lastGroupField);
  399. this.cm.setHidden(oldIndex, false);
  400. this.lastGroupField = groupField;
  401. this.cm.setHidden(colIndex, true);
  402. }
  403. }
  404. return Ext.grid.GroupingView.superclass.renderRows.apply(
  405. this, arguments);
  406. },
  407. // private
  408. doRender : function(cs, rs, ds, startRow, colCount, stripe){
  409. if(rs.length < 1){
  410. return '';
  411. }
  412. if(!this.canGroup() || this.isUpdating){
  413. return Ext.grid.GroupingView.superclass.doRender.apply(this, arguments);
  414. }
  415. var groupField = this.getGroupField(),
  416. colIndex = this.cm.findColumnIndex(groupField),
  417. g,
  418. gstyle = 'width:' + this.getTotalWidth() + ';',
  419. cfg = this.cm.config[colIndex],
  420. groupRenderer = cfg.groupRenderer || cfg.renderer,
  421. prefix = this.showGroupName ? (cfg.groupName || cfg.header)+': ' : '',
  422. groups = [],
  423. curGroup, i, len, gid;
  424. for(i = 0, len = rs.length; i < len; i++){
  425. var rowIndex = startRow + i,
  426. r = rs[i],
  427. gvalue = r.data[groupField];
  428. g = this.getGroup(gvalue, r, groupRenderer, rowIndex, colIndex, ds);
  429. if(!curGroup || curGroup.group != g){
  430. gid = this.constructId(gvalue, groupField, colIndex);
  431. // if state is defined use it, however state is in terms of expanded
  432. // so negate it, otherwise use the default.
  433. this.state[gid] = !(Ext.isDefined(this.state[gid]) ? !this.state[gid] : this.startCollapsed);
  434. curGroup = {
  435. group: g,
  436. gvalue: gvalue,
  437. text: prefix + g,
  438. groupId: gid,
  439. startRow: rowIndex,
  440. rs: [r],
  441. cls: this.state[gid] ? '' : 'x-grid-group-collapsed',
  442. style: gstyle
  443. };
  444. groups.push(curGroup);
  445. }else{
  446. curGroup.rs.push(r);
  447. }
  448. r._groupId = gid;
  449. }
  450. var buf = [];
  451. for(i = 0, len = groups.length; i < len; i++){
  452. g = groups[i];
  453. this.doGroupStart(buf, g, cs, ds, colCount);
  454. buf[buf.length] = Ext.grid.GroupingView.superclass.doRender.call(
  455. this, cs, g.rs, ds, g.startRow, colCount, stripe);
  456. this.doGroupEnd(buf, g, cs, ds, colCount);
  457. }
  458. return buf.join('');
  459. },
  460. /**
  461. * Dynamically tries to determine the groupId of a specific value
  462. * @param {String} value
  463. * @return {String} The group id
  464. */
  465. getGroupId : function(value){
  466. var field = this.getGroupField();
  467. return this.constructId(value, field, this.cm.findColumnIndex(field));
  468. },
  469. // private
  470. constructId : function(value, field, idx){
  471. var cfg = this.cm.config[idx],
  472. groupRenderer = cfg.groupRenderer || cfg.renderer,
  473. val = (this.groupMode == 'value') ? value : this.getGroup(value, {data:{}}, groupRenderer, 0, idx, this.ds);
  474. return this.getPrefix(field) + Ext.util.Format.htmlEncode(val);
  475. },
  476. // private
  477. canGroup : function(){
  478. return this.enableGrouping && !!this.getGroupField();
  479. },
  480. // private
  481. getPrefix: function(field){
  482. return this.grid.getGridEl().id + '-gp-' + field + '-';
  483. },
  484. // private
  485. doGroupStart : function(buf, g, cs, ds, colCount){
  486. buf[buf.length] = this.startGroup.apply(g);
  487. },
  488. // private
  489. doGroupEnd : function(buf, g, cs, ds, colCount){
  490. buf[buf.length] = this.endGroup;
  491. },
  492. // private
  493. getRows : function(){
  494. if(!this.canGroup()){
  495. return Ext.grid.GroupingView.superclass.getRows.call(this);
  496. }
  497. var r = [],
  498. gs = this.getGroups(),
  499. g,
  500. i = 0,
  501. len = gs.length,
  502. j,
  503. jlen;
  504. for(; i < len; ++i){
  505. g = gs[i].childNodes[1];
  506. if(g){
  507. g = g.childNodes;
  508. for(j = 0, jlen = g.length; j < jlen; ++j){
  509. r[r.length] = g[j];
  510. }
  511. }
  512. }
  513. return r;
  514. },
  515. // private
  516. updateGroupWidths : function(){
  517. if(!this.canGroup() || !this.hasRows()){
  518. return;
  519. }
  520. var tw = Math.max(this.cm.getTotalWidth(), this.el.dom.offsetWidth-this.getScrollOffset()) +'px';
  521. var gs = this.getGroups();
  522. for(var i = 0, len = gs.length; i < len; i++){
  523. gs[i].firstChild.style.width = tw;
  524. }
  525. },
  526. // private
  527. onColumnWidthUpdated : function(col, w, tw){
  528. Ext.grid.GroupingView.superclass.onColumnWidthUpdated.call(this, col, w, tw);
  529. this.updateGroupWidths();
  530. },
  531. // private
  532. onAllColumnWidthsUpdated : function(ws, tw){
  533. Ext.grid.GroupingView.superclass.onAllColumnWidthsUpdated.call(this, ws, tw);
  534. this.updateGroupWidths();
  535. },
  536. // private
  537. onColumnHiddenUpdated : function(col, hidden, tw){
  538. Ext.grid.GroupingView.superclass.onColumnHiddenUpdated.call(this, col, hidden, tw);
  539. this.updateGroupWidths();
  540. },
  541. // private
  542. onLayout : function(){
  543. this.updateGroupWidths();
  544. },
  545. // private
  546. onBeforeRowSelect : function(sm, rowIndex){
  547. this.toggleRowIndex(rowIndex, true);
  548. }
  549. });
  550. // private
  551. Ext.grid.GroupingView.GROUP_ID = 1000;