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>
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
15 Ext.ns('Ext.ux.grid');
18 * @class Ext.ux.grid.BufferView
19 * @extends Ext.grid.GridView
20 * A custom GridView which renders rows on an as-needed basis.
22 Ext.ux.grid.BufferView = Ext.extend(Ext.grid.GridView, {
23 <div id="cfg-Ext.ux.grid.BufferView-rowHeight"></div>/**
24 * @cfg {Number} rowHeight
25 * The height of a row in the grid.
29 <div id="cfg-Ext.ux.grid.BufferView-borderHeight"></div>/**
30 * @cfg {Number} borderHeight
31 * The combined height of border-top and border-bottom of a row.
35 <div id="cfg-Ext.ux.grid.BufferView-scrollDelay"></div>/**
36 * @cfg {Boolean/Number} scrollDelay
37 * The number of milliseconds before rendering rows out of the visible
38 * viewing area. Defaults to 100. Rows will render immediately with a config
43 <div id="cfg-Ext.ux.grid.BufferView-cacheSize"></div>/**
44 * @cfg {Number} cacheSize
45 * The number of rows to look forward and backwards from the currently viewable
46 * area. The cache applies only to rows that have been rendered already.
50 <div id="cfg-Ext.ux.grid.BufferView-cleanDelay"></div>/**
51 * @cfg {Number} cleanDelay
52 * The number of milliseconds to buffer cleaning of extra rows not in the
57 initTemplates : function(){
58 Ext.ux.grid.BufferView.superclass.initTemplates.call(this);
59 var ts = this.templates;
60 // empty div to act as a place holder for a row
61 ts.rowHolder = new Ext.Template(
62 '<div class="x-grid3-row {alt}" style="{tstyle}"></div>'
64 ts.rowHolder.disableFormats = true;
65 ts.rowHolder.compile();
67 ts.rowBody = new Ext.Template(
68 '<table class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
69 '<tbody><tr>{cells}</tr>',
70 (this.enableRowBody ? '<tr class="x-grid3-row-body-tr" style="{bodyStyle}"><td colspan="{cols}" class="x-grid3-body-cell" tabIndex="0" hidefocus="on"><div class="x-grid3-row-body">{body}</div></td></tr>' : ''),
73 ts.rowBody.disableFormats = true;
77 getStyleRowHeight : function(){
78 return Ext.isBorderBox ? (this.rowHeight + this.borderHeight) : this.rowHeight;
81 getCalculatedRowHeight : function(){
82 return this.rowHeight + this.borderHeight;
85 getVisibleRowCount : function(){
86 var rh = this.getCalculatedRowHeight(),
87 visibleHeight = this.scroller.dom.clientHeight;
88 return (visibleHeight < 1) ? 0 : Math.ceil(visibleHeight / rh);
91 getVisibleRows: function(){
92 var count = this.getVisibleRowCount(),
93 sc = this.scroller.dom.scrollTop,
94 start = (sc === 0 ? 0 : Math.floor(sc/this.getCalculatedRowHeight())-1);
96 first: Math.max(start, 0),
97 last: Math.min(start + count + 2, this.ds.getCount()-1)
101 doRender : function(cs, rs, ds, startRow, colCount, stripe, onlyBody){
102 var ts = this.templates,
107 rh = this.getStyleRowHeight(),
108 vr = this.getVisibleRows(),
109 tstyle = 'width:'+this.getTotalWidth()+';height:'+rh+'px;',
115 rp = {tstyle: tstyle},
117 for (var j = 0, len = rs.length; j < len; j++) {
119 var rowIndex = (j+startRow),
120 visible = rowIndex >= vr.first && rowIndex <= vr.last;
122 for (var i = 0; i < colCount; i++) {
125 p.css = i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
126 p.attr = p.cellAttr = "";
127 p.value = c.renderer(r.data[c.name], p, r, rowIndex, i, ds);
129 if (p.value === undefined || p.value === "") {
132 if (r.dirty && typeof r.modified[c.name] !== 'undefined') {
133 p.css += ' x-grid3-dirty-cell';
135 cb[cb.length] = ct.apply(p);
139 if(stripe && ((rowIndex+1) % 2 === 0)){
140 alt[0] = "x-grid3-row-alt";
143 alt[1] = " x-grid3-dirty-row";
146 if(this.getRowClass){
147 alt[2] = this.getRowClass(r, rowIndex, rp, ds);
149 rp.alt = alt.join(" ");
150 rp.cells = cb.join("");
151 buf[buf.length] = !visible ? ts.rowHolder.apply(rp) : (onlyBody ? rb.apply(rp) : rt.apply(rp));
156 isRowRendered: function(index){
157 var row = this.getRow(index);
158 return row && row.childNodes.length > 0;
161 syncScroll: function(){
162 Ext.ux.grid.BufferView.superclass.syncScroll.apply(this, arguments);
166 // a (optionally) buffered method to update contents of gridview
168 if (this.scrollDelay) {
169 if (!this.renderTask) {
170 this.renderTask = new Ext.util.DelayedTask(this.doUpdate, this);
172 this.renderTask.delay(this.scrollDelay);
178 onRemove : function(ds, record, index, isUpdate){
179 Ext.ux.grid.BufferView.superclass.onRemove.apply(this, arguments);
180 if(isUpdate !== true){
185 doUpdate: function(){
186 if (this.getVisibleRowCount() > 0) {
190 cs = this.getColumnData(),
191 vr = this.getVisibleRows(),
193 for (var i = vr.first; i <= vr.last; i++) {
194 // if row is NOT rendered and is visible, render it
195 if(!this.isRowRendered(i) && (row = this.getRow(i))){
196 var html = this.doRender(cs, [ds.getAt(i)], ds, i, cm.getColumnCount(), g.stripeRows, true);
197 row.innerHTML = html;
204 // a buffered method to clean rows
207 this.cleanTask = new Ext.util.DelayedTask(this.doClean, this);
209 this.cleanTask.delay(this.cleanDelay);
213 if (this.getVisibleRowCount() > 0) {
214 var vr = this.getVisibleRows();
215 vr.first -= this.cacheSize;
216 vr.last += this.cacheSize;
218 var i = 0, rows = this.getRows();
219 // if first is less than 0, all rows have been rendered
220 // so lets clean the end...
224 for(var len = this.ds.getCount(); i < len; i++){
225 // if current row is outside of first and last and
226 // has content, update the innerHTML to nothing
227 if ((i < vr.first || i > vr.last) && rows[i].innerHTML) {
228 rows[i].innerHTML = '';
234 removeTask: function(name){
235 var task = this[name];
236 if(task && task.cancel){
242 destroy : function(){
243 this.removeTask('cleanTask');
244 this.removeTask('renderTask');
245 Ext.ux.grid.BufferView.superclass.destroy.call(this);
249 Ext.ux.grid.BufferView.superclass.layout.call(this);
252 });// We are adding these custom layouts to a namespace that does not
253 // exist by default in Ext, so we have to add the namespace first:
254 Ext.ns('Ext.ux.layout');
256 <div id="cls-Ext.ux.layout.CenterLayout"></div>/**
257 * @class Ext.ux.layout.CenterLayout
258 * @extends Ext.layout.FitLayout
259 * <p>This is a very simple layout style used to center contents within a container. This layout works within
260 * nested containers and can also be used as expected as a Viewport layout to center the page layout.</p>
261 * <p>As a subclass of FitLayout, CenterLayout expects to have a single child panel of the container that uses
262 * the layout. The layout does not require any config options, although the child panel contained within the
263 * layout must provide a fixed or percentage width. The child panel's height will fit to the container by
264 * default, but you can specify <tt>autoHeight:true</tt> to allow it to autosize based on its content height.
267 // The content panel is centered in the container
268 var p = new Ext.Panel({
269 title: 'Center Layout',
272 title: 'Centered Content',
278 // If you leave the title blank and specify no border
279 // you'll create a non-visual, structural panel just
280 // for centering the contents in the main container.
281 var p = new Ext.Panel({
285 title: 'Centered Content',
293 Ext.ux.layout.CenterLayout = Ext.extend(Ext.layout.FitLayout, {
295 setItemSize : function(item, size){
296 this.container.addClass('ux-layout-center');
297 item.addClass('ux-layout-center-item');
298 if(item && size.height > 0){
300 size.width = item.width;
307 Ext.Container.LAYOUTS['ux.center'] = Ext.ux.layout.CenterLayout;
308 Ext.ns('Ext.ux.grid');
310 <div id="cls-Ext.ux.grid.CheckColumn"></div>/**
311 * @class Ext.ux.grid.CheckColumn
312 * @extends Ext.grid.Column
313 * <p>A Column subclass which renders a checkbox in each column cell which toggles the truthiness of the associated data field on click.</p>
314 * <p><b>Note. As of ExtJS 3.3 this no longer has to be configured as a plugin of the GridPanel.</b></p>
315 * <p>Example usage:</p>
317 var cm = new Ext.grid.ColumnModel([{
321 xtype: 'checkcolumn',
329 var grid = new Ext.grid.EditorGridPanel({
335 * In addition to toggling a Boolean value within the record data, this
336 * class toggles a css class between <tt>'x-grid3-check-col'</tt> and
337 * <tt>'x-grid3-check-col-on'</tt> to alter the background image used for
340 Ext.ux.grid.CheckColumn = Ext.extend(Ext.grid.Column, {
344 * Process and refire events routed from the GridView's processEvent method.
346 processEvent : function(name, e, grid, rowIndex, colIndex){
347 if (name == 'mousedown') {
348 var record = grid.store.getAt(rowIndex);
349 record.set(this.dataIndex, !record.data[this.dataIndex]);
350 return false; // Cancel row selection.
352 return Ext.grid.ActionColumn.superclass.processEvent.apply(this, arguments);
356 renderer : function(v, p, record){
357 p.css += ' x-grid3-check-col-td';
358 return String.format('<div class="x-grid3-check-col{0}"> </div>', v ? '-on' : '');
361 // Deprecate use as a plugin. Remove in 4.0
365 // register ptype. Deprecate. Remove in 4.0
366 Ext.preg('checkcolumn', Ext.ux.grid.CheckColumn);
368 // backwards compat. Remove in 4.0
369 Ext.grid.CheckColumn = Ext.ux.grid.CheckColumn;
371 // register Column xtype
372 Ext.grid.Column.types.checkcolumn = Ext.ux.grid.CheckColumn;Ext.ns('Ext.ux.grid');
374 Ext.ux.grid.ColumnHeaderGroup = Ext.extend(Ext.util.Observable, {
376 constructor: function(config){
377 this.config = config;
380 init: function(grid){
381 Ext.applyIf(grid.colModel, this.config);
382 Ext.apply(grid.getView(), this.viewConfig);
386 initTemplates: function(){
387 this.constructor.prototype.initTemplates.apply(this, arguments);
388 var ts = this.templates || {};
390 ts.gcell = new Ext.XTemplate('<td class="x-grid3-hd x-grid3-gcell x-grid3-td-{id} ux-grid-hd-group-row-{row} {cls}" style="{style}">', '<div {tooltip} class="x-grid3-hd-inner x-grid3-hd-{id}" unselectable="on" style="{istyle}">', this.grid.enableHdMenu ? '<a class="x-grid3-hd-btn" href="#"></a>' : '', '{value}</div></td>');
393 this.hrowRe = new RegExp("ux-grid-hd-group-row-(\\d+)", "");
396 renderHeaders: function(){
397 var ts = this.templates, headers = [], cm = this.cm, rows = cm.rows, tstyle = 'width:' + this.getTotalWidth() + ';';
399 for(var row = 0, rlen = rows.length; row < rlen; row++){
400 var r = rows[row], cells = [];
401 for(var i = 0, gcol = 0, len = r.length; i < len; i++){
403 group.colspan = group.colspan || 1;
404 var id = this.getColumnId(group.dataIndex ? cm.findColumnIndex(group.dataIndex) : gcol), gs = Ext.ux.grid.ColumnHeaderGroup.prototype.getGroupStyle.call(this, group, gcol);
405 cells[i] = ts.gcell.apply({
406 cls: 'ux-grid-hd-group-cell',
409 style: 'width:' + gs.width + ';' + (gs.hidden ? 'display:none;' : '') + (group.align ? 'text-align:' + group.align + ';' : ''),
410 tooltip: group.tooltip ? (Ext.QuickTips.isEnabled() ? 'ext:qtip' : 'title') + '="' + group.tooltip + '"' : '',
411 istyle: group.align == 'right' ? 'padding-right:16px' : '',
412 btn: this.grid.enableHdMenu && group.header,
413 value: group.header || ' '
415 gcol += group.colspan;
417 headers[row] = ts.header.apply({
419 cells: cells.join('')
422 headers.push(this.constructor.prototype.renderHeaders.apply(this, arguments));
423 return headers.join('');
426 onColumnWidthUpdated: function(){
427 this.constructor.prototype.onColumnWidthUpdated.apply(this, arguments);
428 Ext.ux.grid.ColumnHeaderGroup.prototype.updateGroupStyles.call(this);
431 onAllColumnWidthsUpdated: function(){
432 this.constructor.prototype.onAllColumnWidthsUpdated.apply(this, arguments);
433 Ext.ux.grid.ColumnHeaderGroup.prototype.updateGroupStyles.call(this);
436 onColumnHiddenUpdated: function(){
437 this.constructor.prototype.onColumnHiddenUpdated.apply(this, arguments);
438 Ext.ux.grid.ColumnHeaderGroup.prototype.updateGroupStyles.call(this);
441 getHeaderCell: function(index){
442 return this.mainHd.query(this.cellSelector)[index];
445 findHeaderCell: function(el){
446 return el ? this.fly(el).findParent('td.x-grid3-hd', this.cellSelectorDepth) : false;
449 findHeaderIndex: function(el){
450 var cell = this.findHeaderCell(el);
451 return cell ? this.getCellIndex(cell) : false;
454 updateSortIcon: function(col, dir){
455 var sc = this.sortClasses, hds = this.mainHd.select(this.cellSelector).removeClass(sc);
456 hds.item(col).addClass(sc[dir == "DESC" ? 1 : 0]);
459 handleHdDown: function(e, t){
461 if(el.hasClass('x-grid3-hd-btn')){
463 var hd = this.findHeaderCell(t);
464 Ext.fly(hd).addClass('x-grid3-hd-menu-open');
465 var index = this.getCellIndex(hd);
466 this.hdCtxIndex = index;
467 var ms = this.hmenu.items, cm = this.cm;
468 ms.get('asc').setDisabled(!cm.isSortable(index));
469 ms.get('desc').setDisabled(!cm.isSortable(index));
470 this.hmenu.on('hide', function(){
471 Ext.fly(hd).removeClass('x-grid3-hd-menu-open');
475 this.hmenu.show(t, 'tl-bl?');
476 }else if(el.hasClass('ux-grid-hd-group-cell') || Ext.fly(t).up('.ux-grid-hd-group-cell')){
481 handleHdMove: function(e, t){
482 var hd = this.findHeaderCell(this.activeHdRef);
483 if(hd && !this.headersDisabled && !Ext.fly(hd).hasClass('ux-grid-hd-group-cell')){
484 var hw = this.splitHandleWidth || 5, r = this.activeHdRegion, x = e.getPageX(), ss = hd.style, cur = '';
485 if(this.grid.enableColumnResize !== false){
486 if(x - r.left <= hw && this.cm.isResizable(this.activeHdIndex - 1)){
487 cur = Ext.isAir ? 'move' : Ext.isWebKit ? 'e-resize' : 'col-resize'; // col-resize
491 }else if(r.right - x <= (!this.activeHdBtn ? hw : 2) && this.cm.isResizable(this.activeHdIndex)){
492 cur = Ext.isAir ? 'move' : Ext.isWebKit ? 'w-resize' : 'col-resize';
499 handleHdOver: function(e, t){
500 var hd = this.findHeaderCell(t);
501 if(hd && !this.headersDisabled){
502 this.activeHdRef = t;
503 this.activeHdIndex = this.getCellIndex(hd);
504 var fly = this.fly(hd);
505 this.activeHdRegion = fly.getRegion();
506 if(!(this.cm.isMenuDisabled(this.activeHdIndex) || fly.hasClass('ux-grid-hd-group-cell'))){
507 fly.addClass('x-grid3-hd-over');
508 this.activeHdBtn = fly.child('.x-grid3-hd-btn');
509 if(this.activeHdBtn){
510 this.activeHdBtn.dom.style.height = (hd.firstChild.offsetHeight - 1) + 'px';
516 handleHdOut: function(e, t){
517 var hd = this.findHeaderCell(t);
518 if(hd && (!Ext.isIE || !e.within(hd, true))){
519 this.activeHdRef = null;
520 this.fly(hd).removeClass('x-grid3-hd-over');
521 hd.style.cursor = '';
525 handleHdMenuClick: function(item){
526 var index = this.hdCtxIndex, cm = this.cm, ds = this.ds, id = item.getItemId();
529 ds.sort(cm.getDataIndex(index), 'ASC');
532 ds.sort(cm.getDataIndex(index), 'DESC');
535 if(id.substr(0, 6) == 'group-'){
536 var i = id.split('-'), row = parseInt(i[1], 10), col = parseInt(i[2], 10), r = this.cm.rows[row], group, gcol = 0;
537 for(var i = 0, len = r.length; i < len; i++){
539 if(col >= gcol && col < gcol + group.colspan){
542 gcol += group.colspan;
545 var max = cm.getColumnsBy(this.isHideableColumn, this).length;
546 for(var i = gcol, len = gcol + group.colspan; i < len; i++){
552 this.onDenyColumnHide();
556 for(var i = gcol, len = gcol + group.colspan; i < len; i++){
557 if(cm.config[i].fixed !== true && cm.config[i].hideable !== false){
558 cm.setHidden(i, item.checked);
561 }else if(id.substr(0, 4) == 'col-'){
562 index = cm.getIndexById(id.substr(4));
564 if(item.checked && cm.getColumnsBy(this.isHideableColumn, this).length <= 1){
565 this.onDenyColumnHide();
568 cm.setHidden(index, item.checked);
571 if(id.substr(0, 6) == 'group-' || id.substr(0, 4) == 'col-'){
572 item.checked = !item.checked;
574 var updateChildren = function(menu){
575 menu.items.each(function(childItem){
576 if(!childItem.disabled){
577 childItem.setChecked(item.checked, false);
579 updateChildren(childItem.menu);
584 updateChildren(item.menu);
586 var parentMenu = item, parentItem;
587 while(parentMenu = parentMenu.parentMenu){
588 if(!parentMenu.parentMenu || !(parentItem = parentMenu.parentMenu.items.get(parentMenu.getItemId())) || !parentItem.setChecked){
591 var checked = parentMenu.items.findIndexBy(function(m){
594 parentItem.setChecked(checked, true);
596 item.checked = !item.checked;
602 beforeColMenuShow: function(){
603 var cm = this.cm, rows = this.cm.rows;
604 this.colMenu.removeAll();
605 for(var col = 0, clen = cm.getColumnCount(); col < clen; col++){
606 var menu = this.colMenu, title = cm.getColumnHeader(col), text = [];
607 if(cm.config[col].fixed !== true && cm.config[col].hideable !== false){
608 for(var row = 0, rlen = rows.length; row < rlen; row++){
609 var r = rows[row], group, gcol = 0;
610 for(var i = 0, len = r.length; i < len; i++){
612 if(col >= gcol && col < gcol + group.colspan){
615 gcol += group.colspan;
617 if(group && group.header){
618 if(cm.hierarchicalColMenu){
619 var gid = 'group-' + row + '-' + gcol,
620 item = menu.items ? menu.getComponent(gid) : null,
621 submenu = item ? item.menu : null;
623 submenu = new Ext.menu.Menu({
626 submenu.on("itemclick", this.handleHdMenuClick, this);
627 var checked = false, disabled = true;
628 for(var c = gcol, lc = gcol + group.colspan; c < lc; c++){
632 if(cm.config[c].hideable !== false){
647 text.push(group.header);
652 menu.add(new Ext.menu.CheckItem({
653 itemId: "col-" + cm.getColumnId(col),
654 text: text.join(' '),
655 checked: !cm.isHidden(col),
657 disabled: cm.config[col].hideable === false
663 afterRenderUI: function(){
664 this.constructor.prototype.afterRenderUI.apply(this, arguments);
665 Ext.apply(this.columnDrop, Ext.ux.grid.ColumnHeaderGroup.prototype.columnDropConfig);
666 Ext.apply(this.splitZone, Ext.ux.grid.ColumnHeaderGroup.prototype.splitZoneConfig);
671 allowHeaderDrag: function(e){
672 return !e.getTarget(null, null, true).hasClass('ux-grid-hd-group-cell');
677 getTargetFromEvent: function(e){
678 var t = Ext.lib.Event.getTarget(e);
679 return this.view.findHeaderCell(t);
682 positionIndicator: function(h, n, e){
683 var data = Ext.ux.grid.ColumnHeaderGroup.prototype.getDragDropData.call(this, h, n, e);
687 var px = data.px + this.proxyOffsets[0];
688 this.proxyTop.setLeftTop(px, data.r.top + this.proxyOffsets[1]);
689 this.proxyTop.show();
690 this.proxyBottom.setLeftTop(px, data.r.bottom);
691 this.proxyBottom.show();
695 onNodeDrop: function(n, dd, e, data){
698 var d = Ext.ux.grid.ColumnHeaderGroup.prototype.getDragDropData.call(this, h, n, e);
702 var cm = this.grid.colModel, right = d.oldIndex < d.newIndex, rows = cm.rows;
703 for(var row = d.row, rlen = rows.length; row < rlen; row++){
704 var r = rows[row], len = r.length, fromIx = 0, span = 1, toIx = len;
705 for(var i = 0, gcol = 0; i < len; i++){
707 if(d.oldIndex >= gcol && d.oldIndex < gcol + group.colspan){
710 if(d.oldIndex + d.colspan - 1 >= gcol && d.oldIndex + d.colspan - 1 < gcol + group.colspan){
711 span = i - fromIx + 1;
713 if(d.newIndex >= gcol && d.newIndex < gcol + group.colspan){
716 gcol += group.colspan;
718 var groups = r.splice(fromIx, span);
719 rows[row] = r.splice(0, toIx - (right ? span : 0)).concat(groups).concat(r);
721 for(var c = 0; c < d.colspan; c++){
722 var oldIx = d.oldIndex + (right ? 0 : c), newIx = d.newIndex + (right ? -1 : c);
723 cm.moveColumn(oldIx, newIx);
724 this.grid.fireEvent("columnmove", oldIx, newIx);
732 getGroupStyle: function(group, gcol){
733 var width = 0, hidden = true;
734 for(var i = gcol, len = gcol + group.colspan; i < len; i++){
735 if(!this.cm.isHidden(i)){
736 var cw = this.cm.getColumnWidth(i);
737 if(typeof cw == 'number'){
744 width: (Ext.isBorderBox || (Ext.isWebKit && !Ext.isSafari2) ? width : Math.max(width - this.borderWidth, 0)) + 'px',
749 updateGroupStyles: function(col){
750 var tables = this.mainHd.query('.x-grid3-header-offset > table'), tw = this.getTotalWidth(), rows = this.cm.rows;
751 for(var row = 0; row < tables.length; row++){
752 tables[row].style.width = tw;
753 if(row < rows.length){
754 var cells = tables[row].firstChild.firstChild.childNodes;
755 for(var i = 0, gcol = 0; i < cells.length; i++){
756 var group = rows[row][i];
757 if((typeof col != 'number') || (col >= gcol && col < gcol + group.colspan)){
758 var gs = Ext.ux.grid.ColumnHeaderGroup.prototype.getGroupStyle.call(this, group, gcol);
759 cells[i].style.width = gs.width;
760 cells[i].style.display = gs.hidden ? 'none' : '';
762 gcol += group.colspan;
768 getGroupRowIndex: function(el){
770 var m = el.className.match(this.hrowRe);
772 return parseInt(m[1], 10);
775 return this.cm.rows.length;
778 getGroupSpan: function(row, col){
782 colspan: this.cm.getColumnCount()
785 var r = this.cm.rows[row];
787 for(var i = 0, gcol = 0, len = r.length; i < len; i++){
789 if(col >= gcol && col < gcol + group.colspan){
792 colspan: group.colspan
795 gcol += group.colspan;
808 getDragDropData: function(h, n, e){
809 if(h.parentNode != n.parentNode){
812 var cm = this.grid.colModel, x = Ext.lib.Event.getPageX(e), r = Ext.lib.Dom.getRegion(n.firstChild), px, pt;
813 if((r.right - x) <= (r.right - r.left) / 2){
814 px = r.right + this.view.borderWidth;
820 var oldIndex = this.view.getCellIndex(h), newIndex = this.view.getCellIndex(n);
821 if(cm.isFixed(newIndex)){
824 var row = Ext.ux.grid.ColumnHeaderGroup.prototype.getGroupRowIndex.call(this.view, h),
825 oldGroup = Ext.ux.grid.ColumnHeaderGroup.prototype.getGroupSpan.call(this.view, row, oldIndex),
826 newGroup = Ext.ux.grid.ColumnHeaderGroup.prototype.getGroupSpan.call(this.view, row, newIndex),
827 oldIndex = oldGroup.col;
828 newIndex = newGroup.col + (pt == "after" ? newGroup.colspan : 0);
829 if(newIndex >= oldGroup.col && newIndex <= oldGroup.col + oldGroup.colspan){
832 var parentGroup = Ext.ux.grid.ColumnHeaderGroup.prototype.getGroupSpan.call(this.view, row - 1, oldIndex);
833 if(newIndex < parentGroup.col || newIndex > parentGroup.col + parentGroup.colspan){
843 colspan: oldGroup.colspan
846 });Ext.ns('Ext.ux.tree');
848 <div id="cls-Ext.ux.tree.ColumnTree"></div>/**
849 * @class Ext.ux.tree.ColumnTree
850 * @extends Ext.tree.TreePanel
854 Ext.ux.tree.ColumnTree = Ext.extend(Ext.tree.TreePanel, {
856 borderWidth : Ext.isBorderBox ? 0 : 2, // the combined left/right border for each cell
857 cls : 'x-column-tree',
859 onRender : function(){
860 Ext.tree.ColumnTree.superclass.onRender.apply(this, arguments);
861 this.headers = this.header.createChild({cls:'x-tree-headers'});
863 var cols = this.columns, c;
865 var scrollOffset = 19; // similar to Ext.grid.GridView default
867 for(var i = 0, len = cols.length; i < len; i++){
869 totalWidth += c.width;
870 this.headers.createChild({
871 cls:'x-tree-hd ' + (c.cls?c.cls+'-hd':''),
873 cls:'x-tree-hd-text',
876 style:'width:'+(c.width-this.borderWidth)+'px;'
879 this.headers.createChild({cls:'x-clear'});
880 // prevent floats from wrapping when clipped
881 this.headers.setWidth(totalWidth+scrollOffset);
882 this.innerCt.setWidth(totalWidth);
886 Ext.reg('columntree', Ext.ux.tree.ColumnTree);
889 Ext.tree.ColumnTree = Ext.ux.tree.ColumnTree;
892 <div id="cls-Ext.ux.tree.ColumnNodeUI"></div>/**
893 * @class Ext.ux.tree.ColumnNodeUI
894 * @extends Ext.tree.TreeNodeUI
896 Ext.ux.tree.ColumnNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
897 focus: Ext.emptyFn, // prevent odd scrolling behavior
899 renderElements : function(n, a, targetNode, bulkRender){
900 this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
902 var t = n.getOwnerTree();
903 var cols = t.columns;
904 var bw = t.borderWidth;
908 '<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf ', a.cls,'">',
909 '<div class="x-tree-col" style="width:',c.width-bw,'px;">',
910 '<span class="x-tree-node-indent">',this.indentMarkup,"</span>",
911 '<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow">',
912 '<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon',(a.icon ? " x-tree-node-inline-icon" : ""),(a.iconCls ? " "+a.iconCls : ""),'" unselectable="on">',
913 '<a hidefocus="on" class="x-tree-node-anchor" href="',a.href ? a.href : "#",'" tabIndex="1" ',
914 a.hrefTarget ? ' target="'+a.hrefTarget+'"' : "", '>',
915 '<span unselectable="on">', n.text || (c.renderer ? c.renderer(a[c.dataIndex], n, a) : a[c.dataIndex]),"</span></a>",
917 for(var i = 1, len = cols.length; i < len; i++){
920 buf.push('<div class="x-tree-col ',(c.cls?c.cls:''),'" style="width:',c.width-bw,'px;">',
921 '<div class="x-tree-col-text">',(c.renderer ? c.renderer(a[c.dataIndex], n, a) : a[c.dataIndex]),"</div>",
925 '<div class="x-clear"></div></div>',
926 '<ul class="x-tree-node-ct" style="display:none;"></ul>',
929 if(bulkRender !== true && n.nextSibling && n.nextSibling.ui.getEl()){
930 this.wrap = Ext.DomHelper.insertHtml("beforeBegin",
931 n.nextSibling.ui.getEl(), buf.join(""));
933 this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf.join(""));
936 this.elNode = this.wrap.childNodes[0];
937 this.ctNode = this.wrap.childNodes[1];
938 var cs = this.elNode.firstChild.childNodes;
939 this.indentNode = cs[0];
941 this.iconNode = cs[2];
943 this.textNode = cs[3].firstChild;
948 Ext.tree.ColumnNodeUI = Ext.ux.tree.ColumnNodeUI;
949 <div id="cls-Ext.DataView.LabelEditor"></div>/**
950 * @class Ext.DataView.LabelEditor
951 * @extends Ext.Editor
954 Ext.DataView.LabelEditor = Ext.extend(Ext.Editor, {
957 cls: "x-small-editor",
959 completeOnEnter: true,
961 labelSelector: 'span.x-editable',
963 constructor: function(cfg, field){
964 Ext.DataView.LabelEditor.superclass.constructor.call(this,
965 field || new Ext.form.TextField({
975 init : function(view){
977 view.on('render', this.initEditor, this);
978 this.on('complete', this.onSave, this);
981 initEditor : function(){
984 containerclick: this.doBlur,
987 this.view.getEl().on('mousedown', this.onMouseDown, this, {delegate: this.labelSelector});
996 onMouseDown : function(e, target){
997 if(!e.ctrlKey && !e.shiftKey){
998 var item = this.view.findItemFromChild(target);
1000 var record = this.view.store.getAt(this.view.indexOf(item));
1001 this.startEdit(target, record.data[this.dataIndex]);
1002 this.activeRecord = record;
1008 onSave : function(ed, value){
1009 this.activeRecord.set(this.dataIndex, value);
1014 Ext.DataView.DragSelector = function(cfg){
1016 var view, proxy, tracker;
1017 var rs, bodyRegion, dragRegion = new Ext.lib.Region(0,0,0,0);
1018 var dragSafe = cfg.dragSafe === true;
1020 this.init = function(dataView){
1022 view.on('render', onRender);
1025 function fillRegions(){
1027 view.all.each(function(el){
1028 rs[rs.length] = el.getRegion();
1030 bodyRegion = view.el.getRegion();
1033 function cancelClick(){
1037 function onBeforeStart(e){
1038 return !dragSafe || e.target == view.el.dom;
1041 function onStart(e){
1042 view.on('containerclick', cancelClick, view, {single:true});
1044 proxy = view.el.createChild({cls:'x-view-selector'});
1046 if(proxy.dom.parentNode !== view.el.dom){
1047 view.el.dom.appendChild(proxy.dom);
1049 proxy.setDisplayed('block');
1052 view.clearSelections();
1056 var startXY = tracker.startXY;
1057 var xy = tracker.getXY();
1059 var x = Math.min(startXY[0], xy[0]);
1060 var y = Math.min(startXY[1], xy[1]);
1061 var w = Math.abs(startXY[0] - xy[0]);
1062 var h = Math.abs(startXY[1] - xy[1]);
1064 dragRegion.left = x;
1066 dragRegion.right = x+w;
1067 dragRegion.bottom = y+h;
1069 dragRegion.constrainTo(bodyRegion);
1070 proxy.setRegion(dragRegion);
1072 for(var i = 0, len = rs.length; i < len; i++){
1073 var r = rs[i], sel = dragRegion.intersect(r);
1074 if(sel && !r.selected){
1076 view.select(i, true);
1077 }else if(!sel && r.selected){
1086 view.un('containerclick', cancelClick, view);
1089 proxy.setDisplayed(false);
1093 function onRender(view){
1094 tracker = new Ext.dd.DragTracker({
1095 onBeforeStart: onBeforeStart,
1100 tracker.initEl(view.el);
1102 };Ext.ns('Ext.ux.form');
1104 <div id="cls-Ext.ux.form.FileUploadField"></div>/**
1105 * @class Ext.ux.form.FileUploadField
1106 * @extends Ext.form.TextField
1107 * Creates a file upload field.
1108 * @xtype fileuploadfield
1110 Ext.ux.form.FileUploadField = Ext.extend(Ext.form.TextField, {
1111 <div id="cfg-Ext.ux.form.FileUploadField-buttonText"></div>/**
1112 * @cfg {String} buttonText The button text to display on the upload button (defaults to
1113 * 'Browse...'). Note that if you supply a value for {@link #buttonCfg}, the buttonCfg.text
1114 * value will be used instead if available.
1116 buttonText: 'Browse...',
1117 <div id="cfg-Ext.ux.form.FileUploadField-buttonOnly"></div>/**
1118 * @cfg {Boolean} buttonOnly True to display the file upload field as a button with no visible
1119 * text field (defaults to false). If true, all inherited TextField members will still be available.
1122 <div id="cfg-Ext.ux.form.FileUploadField-buttonOffset"></div>/**
1123 * @cfg {Number} buttonOffset The number of pixels of space reserved between the button and the text field
1124 * (defaults to 3). Note that this only applies if {@link #buttonOnly} = false.
1127 <div id="cfg-Ext.ux.form.FileUploadField-buttonCfg"></div>/**
1128 * @cfg {Object} buttonCfg A standard {@link Ext.Button} config object.
1134 <div id="method-Ext.ux.form.FileUploadField-autoSize"></div>/**
1138 autoSize: Ext.emptyFn,
1141 initComponent: function(){
1142 Ext.ux.form.FileUploadField.superclass.initComponent.call(this);
1145 <div id="event-Ext.ux.form.FileUploadField-fileselected"></div>/**
1146 * @event fileselected
1147 * Fires when the underlying file input field's value has changed from the user
1148 * selecting a new file from the system file selection dialog.
1149 * @param {Ext.ux.form.FileUploadField} this
1150 * @param {String} value The file value returned by the underlying file input field
1157 onRender : function(ct, position){
1158 Ext.ux.form.FileUploadField.superclass.onRender.call(this, ct, position);
1160 this.wrap = this.el.wrap({cls:'x-form-field-wrap x-form-file-wrap'});
1161 this.el.addClass('x-form-file-text');
1162 this.el.dom.removeAttribute('name');
1163 this.createFileInput();
1165 var btnCfg = Ext.applyIf(this.buttonCfg || {}, {
1166 text: this.buttonText
1168 this.button = new Ext.Button(Ext.apply(btnCfg, {
1169 renderTo: this.wrap,
1170 cls: 'x-form-file-btn' + (btnCfg.iconCls ? ' x-btn-icon' : '')
1173 if(this.buttonOnly){
1175 this.wrap.setWidth(this.button.getEl().getWidth());
1178 this.bindListeners();
1179 this.resizeEl = this.positionEl = this.wrap;
1182 bindListeners: function(){
1185 mouseenter: function() {
1186 this.button.addClass(['x-btn-over','x-btn-focus'])
1188 mouseleave: function(){
1189 this.button.removeClass(['x-btn-over','x-btn-focus','x-btn-click'])
1191 mousedown: function(){
1192 this.button.addClass('x-btn-click')
1194 mouseup: function(){
1195 this.button.removeClass(['x-btn-over','x-btn-focus','x-btn-click'])
1198 var v = this.fileInput.dom.value;
1200 this.fireEvent('fileselected', this, v);
1205 createFileInput : function() {
1206 this.fileInput = this.wrap.createChild({
1207 id: this.getFileInputId(),
1208 name: this.name||this.getId(),
1217 this.fileInput.remove();
1218 this.createFileInput();
1219 this.bindListeners();
1220 Ext.ux.form.FileUploadField.superclass.reset.call(this);
1224 getFileInputId: function(){
1225 return this.id + '-file';
1229 onResize : function(w, h){
1230 Ext.ux.form.FileUploadField.superclass.onResize.call(this, w, h);
1232 this.wrap.setWidth(w);
1234 if(!this.buttonOnly){
1235 var w = this.wrap.getWidth() - this.button.getEl().getWidth() - this.buttonOffset;
1236 this.el.setWidth(w);
1241 onDestroy: function(){
1242 Ext.ux.form.FileUploadField.superclass.onDestroy.call(this);
1243 Ext.destroy(this.fileInput, this.button, this.wrap);
1246 onDisable: function(){
1247 Ext.ux.form.FileUploadField.superclass.onDisable.call(this);
1248 this.doDisable(true);
1251 onEnable: function(){
1252 Ext.ux.form.FileUploadField.superclass.onEnable.call(this);
1253 this.doDisable(false);
1258 doDisable: function(disabled){
1259 this.fileInput.dom.disabled = disabled;
1260 this.button.setDisabled(disabled);
1265 preFocus : Ext.emptyFn,
1268 alignErrorIcon : function(){
1269 this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);
1274 Ext.reg('fileuploadfield', Ext.ux.form.FileUploadField);
1277 Ext.form.FileUploadField = Ext.ux.form.FileUploadField;
1278 <div id="cls-Ext.ux.GMapPanel"></div>/**
1279 * @class Ext.ux.GMapPanel
1280 * @extends Ext.Panel
1281 * @author Shea Frederick
1283 Ext.ux.GMapPanel = Ext.extend(Ext.Panel, {
1284 initComponent : function(){
1296 Ext.applyIf(this,defConfig);
1298 Ext.ux.GMapPanel.superclass.initComponent.call(this);
1301 afterRender : function(){
1303 var wh = this.ownerCt.getSize();
1304 Ext.applyIf(this, wh);
1306 Ext.ux.GMapPanel.superclass.afterRender.call(this);
1308 if (this.gmapType === 'map'){
1309 this.gmap = new GMap2(this.body.dom);
1312 if (this.gmapType === 'panorama'){
1313 this.gmap = new GStreetviewPanorama(this.body.dom);
1316 if (typeof this.addControl == 'object' && this.gmapType === 'map') {
1317 this.gmap.addControl(this.addControl);
1320 if (typeof this.setCenter === 'object') {
1321 if (typeof this.setCenter.geoCodeAddr === 'string'){
1322 this.geoCodeLookup(this.setCenter.geoCodeAddr);
1324 if (this.gmapType === 'map'){
1325 var point = new GLatLng(this.setCenter.lat,this.setCenter.lng);
1326 this.gmap.setCenter(point, this.zoomLevel);
1328 if (typeof this.setCenter.marker === 'object' && typeof point === 'object'){
1329 this.addMarker(point,this.setCenter.marker,this.setCenter.marker.clear);
1332 if (this.gmapType === 'panorama'){
1333 this.gmap.setLocationAndPOV(new GLatLng(this.setCenter.lat,this.setCenter.lng), {yaw: this.yaw, pitch: this.pitch, zoom: this.zoom});
1337 GEvent.bind(this.gmap, 'load', this, function(){
1342 onMapReady : function(){
1343 this.addMarkers(this.markers);
1344 this.addMapControls();
1347 onResize : function(w, h){
1349 if (typeof this.getMap() == 'object') {
1350 this.gmap.checkResize();
1353 Ext.ux.GMapPanel.superclass.onResize.call(this, w, h);
1356 setSize : function(width, height, animate){
1358 if (typeof this.getMap() == 'object') {
1359 this.gmap.checkResize();
1362 Ext.ux.GMapPanel.superclass.setSize.call(this, width, height, animate);
1365 getMap : function(){
1370 getCenter : function(){
1372 return this.getMap().getCenter();
1375 getCenterLatLng : function(){
1377 var ll = this.getCenter();
1378 return {lat: ll.lat(), lng: ll.lng()};
1381 addMarkers : function(markers) {
1383 if (Ext.isArray(markers)){
1384 for (var i = 0; i < markers.length; i++) {
1385 var mkr_point = new GLatLng(markers[i].lat,markers[i].lng);
1386 this.addMarker(mkr_point,markers[i].marker,false,markers[i].setCenter, markers[i].listeners);
1391 addMarker : function(point, marker, clear, center, listeners){
1393 Ext.applyIf(marker,G_DEFAULT_ICON);
1395 if (clear === true){
1396 this.getMap().clearOverlays();
1398 if (center === true) {
1399 this.getMap().setCenter(point, this.zoomLevel);
1402 var mark = new GMarker(point,marker);
1403 if (typeof listeners === 'object'){
1404 for (evt in listeners) {
1405 GEvent.bind(mark, evt, this, listeners[evt]);
1408 this.getMap().addOverlay(mark);
1411 addMapControls : function(){
1413 if (this.gmapType === 'map') {
1414 if (Ext.isArray(this.mapControls)) {
1415 for(i=0;i<this.mapControls.length;i++){
1416 this.addMapControl(this.mapControls[i]);
1418 }else if(typeof this.mapControls === 'string'){
1419 this.addMapControl(this.mapControls);
1420 }else if(typeof this.mapControls === 'object'){
1421 this.getMap().addControl(this.mapControls);
1426 addMapControl : function(mc){
1428 var mcf = window[mc];
1429 if (typeof mcf === 'function') {
1430 this.getMap().addControl(new mcf());
1434 addOptions : function(){
1436 if (Ext.isArray(this.mapConfOpts)) {
1438 for(i=0;i<this.mapConfOpts.length;i++){
1439 this.addOption(this.mapConfOpts[i]);
1441 }else if(typeof this.mapConfOpts === 'string'){
1442 this.addOption(this.mapConfOpts);
1446 addOption : function(mc){
1448 var mcf = this.getMap()[mc];
1449 if (typeof mcf === 'function') {
1450 this.getMap()[mc]();
1454 geoCodeLookup : function(addr) {
1456 this.geocoder = new GClientGeocoder();
1457 this.geocoder.getLocations(addr, this.addAddressToMap.createDelegate(this));
1460 addAddressToMap : function(response) {
1462 if (!response || response.Status.code != 200) {
1463 Ext.MessageBox.alert('Error', 'Code '+response.Status.code+' Error Returned');
1465 place = response.Placemark[0];
1466 addressinfo = place.AddressDetails;
1467 accuracy = addressinfo.Accuracy;
1468 if (accuracy === 0) {
1469 Ext.MessageBox.alert('Unable to Locate Address', 'Unable to Locate the Address you provided');
1472 Ext.MessageBox.alert('Address Accuracy', 'The address provided has a low accuracy.<br><br>Level '+accuracy+' Accuracy (8 = Exact Match, 1 = Vague Match)');
1474 point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
1475 if (typeof this.setCenter.marker === 'object' && typeof point === 'object'){
1476 this.addMarker(point,this.setCenter.marker,this.setCenter.marker.clear,true, this.setCenter.listeners);
1486 Ext.reg('gmappanel', Ext.ux.GMapPanel); Ext.namespace('Ext.ux.grid');
1489 * @class Ext.ux.grid.GridFilters
1490 * @extends Ext.util.Observable
1491 * <p>GridFilter is a plugin (<code>ptype='gridfilters'</code>) for grids that
1492 * allow for a slightly more robust representation of filtering than what is
1493 * provided by the default store.</p>
1494 * <p>Filtering is adjusted by the user using the grid's column header menu
1495 * (this menu can be disabled through configuration). Through this menu users
1496 * can configure, enable, and disable filters for each column.</p>
1497 * <p><b><u>Features:</u></b></p>
1498 * <div class="mdetail-params"><ul>
1499 * <li><b>Filtering implementations</b> :
1500 * <div class="sub-desc">
1501 * Default filtering for Strings, Numeric Ranges, Date Ranges, Lists (which can
1502 * be backed by a Ext.data.Store), and Boolean. Additional custom filter types
1503 * and menus are easily created by extending Ext.ux.grid.filter.Filter.
1505 * <li><b>Graphical indicators</b> :
1506 * <div class="sub-desc">
1507 * Columns that are filtered have {@link #filterCls a configurable css class}
1508 * applied to the column headers.
1510 * <li><b>Paging</b> :
1511 * <div class="sub-desc">
1512 * If specified as a plugin to the grid's configured PagingToolbar, the current page
1513 * will be reset to page 1 whenever you update the filters.
1515 * <li><b>Automatic Reconfiguration</b> :
1516 * <div class="sub-desc">
1517 * Filters automatically reconfigure when the grid 'reconfigure' event fires.
1519 * <li><b>Stateful</b> :
1520 * Filter information will be persisted across page loads by specifying a
1521 * <code>stateId</code> in the Grid configuration.
1522 * <div class="sub-desc">
1523 * The filter collection binds to the
1524 * <code>{@link Ext.grid.GridPanel#beforestaterestore beforestaterestore}</code>
1525 * and <code>{@link Ext.grid.GridPanel#beforestatesave beforestatesave}</code>
1526 * events in order to be stateful.
1528 * <li><b>Grid Changes</b> :
1529 * <div class="sub-desc"><ul>
1530 * <li>A <code>filters</code> <i>property</i> is added to the grid pointing to
1532 * <li>A <code>filterupdate</code> <i>event</i> is added to the grid and is
1533 * fired upon onStateChange completion.</li>
1535 * <li><b>Server side code examples</b> :
1536 * <div class="sub-desc"><ul>
1537 * <li><a href="http://www.vinylfox.com/extjs/grid-filter-php-backend-code.php">PHP</a> - (Thanks VinylFox)</li>
1538 * <li><a href="http://extjs.com/forum/showthread.php?p=77326#post77326">Ruby on Rails</a> - (Thanks Zyclops)</li>
1539 * <li><a href="http://extjs.com/forum/showthread.php?p=176596#post176596">Ruby on Rails</a> - (Thanks Rotomaul)</li>
1540 * <li><a href="http://www.debatablybeta.com/posts/using-extjss-grid-filtering-with-django/">Python</a> - (Thanks Matt)</li>
1541 * <li><a href="http://mcantrell.wordpress.com/2008/08/22/extjs-grids-and-grails/">Grails</a> - (Thanks Mike)</li>
1544 * <p><b><u>Example usage:</u></b></p>
1546 var store = new Ext.data.GroupingStore({
1550 var filters = new Ext.ux.grid.GridFilters({
1551 autoReload: false, //don't reload automatically
1552 local: true, //only filter locally
1553 // filters may be configured through the plugin,
1554 // or in the column definition within the column model configuration
1566 dataIndex: 'dateAdded'
1570 options: ['extra small', 'small', 'medium', 'large', 'extra large'],
1574 dataIndex: 'visible'
1577 var cm = new Ext.grid.ColumnModel([{
1581 var grid = new Ext.grid.GridPanel({
1584 view: new Ext.grid.GroupingView(),
1588 bbar: new Ext.PagingToolbar({
1591 plugins: [filters] //reset page to page 1 if filters change
1595 store.load({params: {start: 0, limit: 15}});
1597 // a filters property is added to the grid
1601 Ext.ux.grid.GridFilters = Ext.extend(Ext.util.Observable, {
1602 <div id="cfg-Ext.ux.grid.GridFilters-autoReload"></div>/**
1603 * @cfg {Boolean} autoReload
1604 * Defaults to true, reloading the datasource when a filter change happens.
1605 * Set this to false to prevent the datastore from being reloaded if there
1606 * are changes to the filters. See <code>{@link updateBuffer}</code>.
1609 <div id="cfg-Ext.ux.grid.GridFilters-encode"></div>/**
1610 * @cfg {Boolean} encode
1611 * Specify true for {@link #buildQuery} to use Ext.util.JSON.encode to
1612 * encode the filter query parameter sent with a remote request.
1613 * Defaults to false.
1615 <div id="cfg-Ext.ux.grid.GridFilters-filters"></div>/**
1616 * @cfg {Array} filters
1617 * An Array of filters config objects. Refer to each filter type class for
1618 * configuration details specific to each filter type. Filters for Strings,
1619 * Numeric Ranges, Date Ranges, Lists, and Boolean are the standard filters
1622 <div id="cfg-Ext.ux.grid.GridFilters-filterCls"></div>/**
1623 * @cfg {String} filterCls
1624 * The css class to be applied to column headers with active filters.
1625 * Defaults to <tt>'ux-filterd-column'</tt>.
1627 filterCls : 'ux-filtered-column',
1628 <div id="cfg-Ext.ux.grid.GridFilters-local"></div>/**
1629 * @cfg {Boolean} local
1630 * <tt>true</tt> to use Ext.data.Store filter functions (local filtering)
1631 * instead of the default (<tt>false</tt>) server side filtering.
1634 <div id="cfg-Ext.ux.grid.GridFilters-menuFilterText"></div>/**
1635 * @cfg {String} menuFilterText
1636 * defaults to <tt>'Filters'</tt>.
1638 menuFilterText : 'Filters',
1639 <div id="cfg-Ext.ux.grid.GridFilters-paramPrefix"></div>/**
1640 * @cfg {String} paramPrefix
1641 * The url parameter prefix for the filters.
1642 * Defaults to <tt>'filter'</tt>.
1644 paramPrefix : 'filter',
1645 <div id="cfg-Ext.ux.grid.GridFilters-showMenu"></div>/**
1646 * @cfg {Boolean} showMenu
1647 * Defaults to true, including a filter submenu in the default header menu.
1650 <div id="cfg-Ext.ux.grid.GridFilters-stateId"></div>/**
1651 * @cfg {String} stateId
1652 * Name of the value to be used to store state information.
1654 stateId : undefined,
1655 <div id="cfg-Ext.ux.grid.GridFilters-updateBuffer"></div>/**
1656 * @cfg {Integer} updateBuffer
1657 * Number of milliseconds to defer store updates since the last filter change.
1662 constructor : function (config) {
1663 config = config || {};
1664 this.deferredUpdate = new Ext.util.DelayedTask(this.reload, this);
1665 this.filters = new Ext.util.MixedCollection();
1666 this.filters.getKey = function (o) {
1667 return o ? o.dataIndex : null;
1669 this.addFilters(config.filters);
1670 delete config.filters;
1671 Ext.apply(this, config);
1675 init : function (grid) {
1676 if (grid instanceof Ext.grid.GridPanel) {
1679 this.bindStore(this.grid.getStore(), true);
1680 // assumes no filters were passed in the constructor, so try and use ones from the colModel
1681 if(this.filters.getCount() == 0){
1682 this.addFilters(this.grid.getColumnModel());
1685 this.grid.filters = this;
1687 this.grid.addEvents({'filterupdate': true});
1691 beforestaterestore: this.applyState,
1692 beforestatesave: this.saveState,
1693 beforedestroy: this.destroy,
1694 reconfigure: this.onReconfigure
1703 render: this.onRender
1707 } else if (grid instanceof Ext.PagingToolbar) {
1708 this.toolbar = grid;
1714 * Handler for the grid's beforestaterestore event (fires before the state of the
1715 * grid is restored).
1716 * @param {Object} grid The grid object
1717 * @param {Object} state The hash of state values returned from the StateProvider.
1719 applyState : function (grid, state) {
1721 this.applyingState = true;
1722 this.clearFilters();
1723 if (state.filters) {
1724 for (key in state.filters) {
1725 filter = this.filters.get(key);
1727 filter.setValue(state.filters[key]);
1728 filter.setActive(true);
1732 this.deferredUpdate.cancel();
1736 delete this.applyingState;
1737 delete state.filters;
1740 <div id="method-Ext.ux.grid.GridFilters-saveState"></div>/**
1741 * Saves the state of all active filters
1742 * @param {Object} grid
1743 * @param {Object} state
1746 saveState : function (grid, state) {
1748 this.filters.each(function (filter) {
1749 if (filter.active) {
1750 filters[filter.dataIndex] = filter.getValue();
1753 return (state.filters = filters);
1758 * Handler called when the grid is rendered
1760 onRender : function () {
1761 this.grid.getView().on('refresh', this.onRefresh, this);
1767 * Handler called by the grid 'beforedestroy' event
1769 destroy : function () {
1771 this.purgeListeners();
1773 if(this.filterMenu){
1774 Ext.menu.MenuMgr.unregister(this.filterMenu);
1775 this.filterMenu.destroy();
1776 this.filterMenu = this.menu.menu = null;
1780 <div id="method-Ext.ux.grid.GridFilters-removeAll"></div>/**
1781 * Remove all filters, permanently destroying them.
1783 removeAll : function () {
1785 Ext.destroy.apply(Ext, this.filters.items);
1786 // remove all items from the collection
1787 this.filters.clear();
1792 <div id="method-Ext.ux.grid.GridFilters-bindStore"></div>/**
1793 * Changes the data store bound to this view and refreshes it.
1794 * @param {Store} store The store to bind to this view
1796 bindStore : function(store, initial){
1797 if(!initial && this.store){
1799 store.un('load', this.onLoad, this);
1801 store.un('beforeload', this.onBeforeLoad, this);
1806 store.on('load', this.onLoad, this);
1808 store.on('beforeload', this.onBeforeLoad, this);
1816 * Handler called when the grid reconfigure event fires
1818 onReconfigure : function () {
1819 this.bindStore(this.grid.getStore());
1820 this.store.clearFilter();
1822 this.addFilters(this.grid.getColumnModel());
1823 this.updateColumnHeadings();
1826 createMenu : function () {
1827 var view = this.grid.getView(),
1830 if (this.showMenu && hmenu) {
1832 this.sep = hmenu.addSeparator();
1833 this.filterMenu = new Ext.menu.Menu({
1834 id: this.grid.id + '-filters-menu'
1836 this.menu = hmenu.add({
1839 text: this.menuFilterText,
1840 menu: this.filterMenu
1845 checkchange: this.onCheckChange,
1846 beforecheckchange: this.onBeforeCheck
1848 hmenu.on('beforeshow', this.onMenu, this);
1850 this.updateColumnHeadings();
1855 * Get the filter menu from the filters MixedCollection based on the clicked header
1857 getMenuFilter : function () {
1858 var view = this.grid.getView();
1859 if (!view || view.hdCtxIndex === undefined) {
1862 return this.filters.get(
1863 view.cm.config[view.hdCtxIndex].dataIndex
1869 * Handler called by the grid's hmenu beforeshow event
1871 onMenu : function (filterMenu) {
1872 var filter = this.getMenuFilter();
1876 TODO: lazy rendering
1878 filter.menu = filter.createMenu();
1881 this.menu.menu = filter.menu;
1882 this.menu.setChecked(filter.active, false);
1883 // disable the menu if filter.disabled explicitly set to true
1884 this.menu.setDisabled(filter.disabled === true);
1887 this.menu.setVisible(filter !== undefined);
1888 this.sep.setVisible(filter !== undefined);
1892 onCheckChange : function (item, value) {
1893 this.getMenuFilter().setActive(value);
1897 onBeforeCheck : function (check, value) {
1898 return !value || this.getMenuFilter().isActivatable();
1903 * Handler for all events on filters.
1904 * @param {String} event Event name
1905 * @param {Object} filter Standard signature of the event before the event is fired
1907 onStateChange : function (event, filter) {
1908 if (event === 'serialize') {
1912 if (filter == this.getMenuFilter()) {
1913 this.menu.setChecked(filter.active, false);
1916 if ((this.autoReload || this.local) && !this.applyingState) {
1917 this.deferredUpdate.delay(this.updateBuffer);
1919 this.updateColumnHeadings();
1921 if (!this.applyingState) {
1922 this.grid.saveState();
1924 this.grid.fireEvent('filterupdate', this, filter);
1929 * Handler for store's beforeload event when configured for remote filtering
1930 * @param {Object} store
1931 * @param {Object} options
1933 onBeforeLoad : function (store, options) {
1934 options.params = options.params || {};
1935 this.cleanParams(options.params);
1936 var params = this.buildQuery(this.getFilterData());
1937 Ext.apply(options.params, params);
1942 * Handler for store's load event when configured for local filtering
1943 * @param {Object} store
1944 * @param {Object} options
1946 onLoad : function (store, options) {
1947 store.filterBy(this.getRecordFilter());
1952 * Handler called when the grid's view is refreshed
1954 onRefresh : function () {
1955 this.updateColumnHeadings();
1958 <div id="method-Ext.ux.grid.GridFilters-updateColumnHeadings"></div>/**
1959 * Update the styles for the header row based on the active filters
1961 updateColumnHeadings : function () {
1962 var view = this.grid.getView(),
1965 for (i = 0, len = view.cm.config.length; i < len; i++) {
1966 filter = this.getFilter(view.cm.config[i].dataIndex);
1967 Ext.fly(view.getHeaderCell(i))[filter && filter.active ? 'addClass' : 'removeClass'](this.filterCls);
1973 reload : function () {
1975 this.grid.store.clearFilter(true);
1976 this.grid.store.filterBy(this.getRecordFilter());
1979 store = this.grid.store;
1980 this.deferredUpdate.cancel();
1982 start = store.paramNames.start;
1983 if (store.lastOptions && store.lastOptions.params && store.lastOptions.params[start]) {
1984 store.lastOptions.params[start] = 0;
1992 * Method factory that generates a record validator for the filters active at the time
1996 getRecordFilter : function () {
1998 this.filters.each(function (filter) {
1999 if (filter.active) {
2005 return function (record) {
2006 for (i = 0; i < len; i++) {
2007 if (!f[i].validateRecord(record)) {
2015 <div id="method-Ext.ux.grid.GridFilters-addFilter"></div>/**
2016 * Adds a filter to the collection and observes it for state change.
2017 * @param {Object/Ext.ux.grid.filter.Filter} config A filter configuration or a filter object.
2018 * @return {Ext.ux.grid.filter.Filter} The existing or newly created filter object.
2020 addFilter : function (config) {
2021 var Cls = this.getFilterClass(config.type),
2022 filter = config.menu ? config : (new Cls(config));
2023 this.filters.add(filter);
2025 Ext.util.Observable.capture(filter, this.onStateChange, this);
2029 <div id="method-Ext.ux.grid.GridFilters-addFilters"></div>/**
2030 * Adds filters to the collection.
2031 * @param {Array/Ext.grid.ColumnModel} filters Either an Array of
2032 * filter configuration objects or an Ext.grid.ColumnModel. The columns
2033 * of a passed Ext.grid.ColumnModel will be examined for a <code>filter</code>
2034 * property and, if present, will be used as the filter configuration object.
2036 addFilters : function (filters) {
2038 var i, len, filter, cm = false, dI;
2039 if (filters instanceof Ext.grid.ColumnModel) {
2040 filters = filters.config;
2043 for (i = 0, len = filters.length; i < len; i++) {
2046 dI = filters[i].dataIndex;
2047 filter = filters[i].filter || filters[i].filterable;
2049 filter = (filter === true) ? {} : filter;
2050 Ext.apply(filter, {dataIndex:dI});
2051 // filter type is specified in order of preference:
2052 // filter type specified in config
2053 // type specified in store's field's type config
2054 filter.type = filter.type || this.store.fields.get(dI).type.type;
2057 filter = filters[i];
2059 // if filter config found add filter for the column
2061 this.addFilter(filter);
2067 <div id="method-Ext.ux.grid.GridFilters-getFilter"></div>/**
2068 * Returns a filter for the given dataIndex, if one exists.
2069 * @param {String} dataIndex The dataIndex of the desired filter object.
2070 * @return {Ext.ux.grid.filter.Filter}
2072 getFilter : function (dataIndex) {
2073 return this.filters.get(dataIndex);
2076 <div id="method-Ext.ux.grid.GridFilters-clearFilters"></div>/**
2077 * Turns all filters off. This does not clear the configuration information
2078 * (see {@link #removeAll}).
2080 clearFilters : function () {
2081 this.filters.each(function (filter) {
2082 filter.setActive(false);
2086 <div id="method-Ext.ux.grid.GridFilters-getFilterData"></div>/**
2087 * Returns an Array of the currently active filters.
2088 * @return {Array} filters Array of the currently active filters.
2090 getFilterData : function () {
2091 var filters = [], i, len;
2093 this.filters.each(function (f) {
2095 var d = [].concat(f.serialize());
2096 for (i = 0, len = d.length; i < len; i++) {
2107 <div id="method-Ext.ux.grid.GridFilters-buildQuery"></div>/**
2108 * Function to take the active filters data and build it into a query.
2109 * The format of the query depends on the <code>{@link #encode}</code>
2111 * <div class="mdetail-params"><ul>
2113 * <li><b><tt>false</tt></b> : <i>Default</i>
2114 * <div class="sub-desc">
2115 * Flatten into query string of the form (assuming <code>{@link #paramPrefix}='filters'</code>:
2117 filters[0][field]="someDataIndex"&
2118 filters[0][data][comparison]="someValue1"&
2119 filters[0][data][type]="someValue2"&
2120 filters[0][data][value]="someValue3"&
2123 * <li><b><tt>true</tt></b> :
2124 * <div class="sub-desc">
2125 * JSON encode the filter data
2127 filters[0][field]="someDataIndex"&
2128 filters[0][data][comparison]="someValue1"&
2129 filters[0][data][type]="someValue2"&
2130 filters[0][data][value]="someValue3"&
2134 * Override this method to customize the format of the filter query for remote requests.
2135 * @param {Array} filters A collection of objects representing active filters and their configuration.
2136 * Each element will take the form of {field: dataIndex, data: filterConf}. dataIndex is not assured
2137 * to be unique as any one filter may be a composite of more basic filters for the same dataIndex.
2138 * @return {Object} Query keys and values
2140 buildQuery : function (filters) {
2141 var p = {}, i, f, root, dataPrefix, key, tmp,
2142 len = filters.length;
2145 for (i = 0; i < len; i++) {
2147 root = [this.paramPrefix, '[', i, ']'].join('');
2148 p[root + '[field]'] = f.field;
2150 dataPrefix = root + '[data]';
2151 for (key in f.data) {
2152 p[[dataPrefix, '[', key, ']'].join('')] = f.data[key];
2157 for (i = 0; i < len; i++) {
2165 // only build if there is active filter
2166 if (tmp.length > 0){
2167 p[this.paramPrefix] = Ext.util.JSON.encode(tmp);
2173 <div id="method-Ext.ux.grid.GridFilters-cleanParams"></div>/**
2174 * Removes filter related query parameters from the provided object.
2175 * @param {Object} p Query parameters that may contain filter related fields.
2177 cleanParams : function (p) {
2178 // if encoding just delete the property
2180 delete p[this.paramPrefix];
2181 // otherwise scrub the object of filter data
2184 regex = new RegExp('^' + this.paramPrefix + '\[[0-9]+\]');
2186 if (regex.test(key)) {
2193 <div id="method-Ext.ux.grid.GridFilters-getFilterClass"></div>/**
2194 * Function for locating filter classes, overwrite this with your favorite
2195 * loader to provide dynamic filter loading.
2196 * @param {String} type The type of filter to load ('Filter' is automatically
2197 * appended to the passed type; eg, 'string' becomes 'StringFilter').
2198 * @return {Class} The Ext.ux.grid.filter.Class
2200 getFilterClass : function (type) {
2201 // map the supported Ext.data.Field type values into a supported filter
2214 return Ext.ux.grid.filter[type.substr(0, 1).toUpperCase() + type.substr(1) + 'Filter'];
2219 Ext.preg('gridfilters', Ext.ux.grid.GridFilters);
2220 Ext.namespace('Ext.ux.grid.filter');
2223 * @class Ext.ux.grid.filter.Filter
2224 * @extends Ext.util.Observable
2225 * Abstract base class for filter implementations.
2227 Ext.ux.grid.filter.Filter = Ext.extend(Ext.util.Observable, {
2228 <div id="cfg-Ext.ux.grid.filter.Filter-active"></div>/**
2229 * @cfg {Boolean} active
2230 * Indicates the initial status of the filter (defaults to false).
2233 <div id="prop-Ext.ux.grid.filter.Filter-active"></div>/**
2234 * True if this filter is active. Use setActive() to alter after configuration.
2238 <div id="cfg-Ext.ux.grid.filter.Filter-dataIndex"></div>/**
2239 * @cfg {String} dataIndex
2240 * The {@link Ext.data.Store} dataIndex of the field this filter represents.
2241 * The dataIndex does not actually have to exist in the store.
2244 <div id="prop-Ext.ux.grid.filter.Filter-menu"></div>/**
2245 * The filter configuration menu that will be installed into the filter submenu of a column menu.
2246 * @type Ext.menu.Menu
2250 <div id="cfg-Ext.ux.grid.filter.Filter-updateBuffer"></div>/**
2251 * @cfg {Number} updateBuffer
2252 * Number of milliseconds to wait after user interaction to fire an update. Only supported
2253 * by filters: 'list', 'numeric', and 'string'. Defaults to 500.
2257 constructor : function (config) {
2258 Ext.apply(this, config);
2261 <div id="event-Ext.ux.grid.filter.Filter-activate"></div>/**
2263 * Fires when an inactive filter becomes active
2264 * @param {Ext.ux.grid.filter.Filter} this
2267 <div id="event-Ext.ux.grid.filter.Filter-deactivate"></div>/**
2269 * Fires when an active filter becomes inactive
2270 * @param {Ext.ux.grid.filter.Filter} this
2273 <div id="event-Ext.ux.grid.filter.Filter-serialize"></div>/**
2275 * Fires after the serialization process. Use this to attach additional parameters to serialization
2276 * data before it is encoded and sent to the server.
2277 * @param {Array/Object} data A map or collection of maps representing the current filter configuration.
2278 * @param {Ext.ux.grid.filter.Filter} filter The filter being serialized.
2281 <div id="event-Ext.ux.grid.filter.Filter-update"></div>/**
2283 * Fires when a filter configuration has changed
2284 * @param {Ext.ux.grid.filter.Filter} this The filter object.
2288 Ext.ux.grid.filter.Filter.superclass.constructor.call(this);
2290 this.menu = new Ext.menu.Menu();
2292 if(config && config.value){
2293 this.setValue(config.value);
2294 this.setActive(config.active !== false, true);
2295 delete config.value;
2299 <div id="method-Ext.ux.grid.filter.Filter-destroy"></div>/**
2300 * Destroys this filter by purging any event listeners, and removing any menus.
2302 destroy : function(){
2304 this.menu.destroy();
2306 this.purgeListeners();
2309 <div id="prop-Ext.ux.grid.filter.Filter-init"></div>/**
2310 * Template method to be implemented by all subclasses that is to
2311 * initialize the filter and install required menu items.
2312 * Defaults to Ext.emptyFn.
2316 <div id="method-Ext.ux.grid.filter.Filter-getValue"></div>/**
2317 * Template method to be implemented by all subclasses that is to
2318 * get and return the value of the filter.
2319 * Defaults to Ext.emptyFn.
2320 * @return {Object} The 'serialized' form of this filter
2321 * @methodOf Ext.ux.grid.filter.Filter
2323 getValue : Ext.emptyFn,
2325 <div id="method-Ext.ux.grid.filter.Filter-setValue"></div>/**
2326 * Template method to be implemented by all subclasses that is to
2327 * set the value of the filter and fire the 'update' event.
2328 * Defaults to Ext.emptyFn.
2329 * @param {Object} data The value to set the filter
2330 * @methodOf Ext.ux.grid.filter.Filter
2332 setValue : Ext.emptyFn,
2334 <div id="method-Ext.ux.grid.filter.Filter-isActivatable"></div>/**
2335 * Template method to be implemented by all subclasses that is to
2336 * return <tt>true</tt> if the filter has enough configuration information to be activated.
2337 * Defaults to <tt>return true</tt>.
2340 isActivatable : function(){
2344 <div id="prop-Ext.ux.grid.filter.Filter-getSerialArgs"></div>/**
2345 * Template method to be implemented by all subclasses that is to
2346 * get and return serialized filter data for transmission to the server.
2347 * Defaults to Ext.emptyFn.
2349 getSerialArgs : Ext.emptyFn,
2351 <div id="method-Ext.ux.grid.filter.Filter-validateRecord"></div>/**
2352 * Template method to be implemented by all subclasses that is to
2353 * validates the provided Ext.data.Record against the filters configuration.
2354 * Defaults to <tt>return true</tt>.
2355 * @param {Ext.data.Record} record The record to validate
2356 * @return {Boolean} true if the record is valid within the bounds
2357 * of the filter, false otherwise.
2359 validateRecord : function(){
2363 <div id="method-Ext.ux.grid.filter.Filter-serialize"></div>/**
2364 * Returns the serialized filter data for transmission to the server
2365 * and fires the 'serialize' event.
2366 * @return {Object/Array} An object or collection of objects containing
2367 * key value pairs representing the current configuration of the filter.
2368 * @methodOf Ext.ux.grid.filter.Filter
2370 serialize : function(){
2371 var args = this.getSerialArgs();
2372 this.fireEvent('serialize', args, this);
2377 fireUpdate : function(){
2379 this.fireEvent('update', this);
2381 this.setActive(this.isActivatable());
2384 <div id="method-Ext.ux.grid.filter.Filter-setActive"></div>/**
2385 * Sets the status of the filter and fires the appropriate events.
2386 * @param {Boolean} active The new filter state.
2387 * @param {Boolean} suppressEvent True to prevent events from being fired.
2388 * @methodOf Ext.ux.grid.filter.Filter
2390 setActive : function(active, suppressEvent){
2391 if(this.active != active){
2392 this.active = active;
2393 if (suppressEvent !== true) {
2394 this.fireEvent(active ? 'activate' : 'deactivate', this);
2399 * @class Ext.ux.grid.filter.BooleanFilter
2400 * @extends Ext.ux.grid.filter.Filter
2401 * Boolean filters use unique radio group IDs (so you can have more than one!)
2402 * <p><b><u>Example Usage:</u></b></p>
2404 var filters = new Ext.ux.grid.GridFilters({
2409 dataIndex: 'visible'
2412 defaultValue: null, // leave unselected (false selected by default)
2413 yesText: 'Yes', // default
2414 noText: 'No' // default
2419 Ext.ux.grid.filter.BooleanFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
2420 <div id="cfg-Ext.ux.grid.filter.BooleanFilter-defaultValue"></div>/**
2421 * @cfg {Boolean} defaultValue
2422 * Set this to null if you do not want either option to be checked by default. Defaults to false.
2424 defaultValue : false,
2425 <div id="cfg-Ext.ux.grid.filter.BooleanFilter-yesText"></div>/**
2426 * @cfg {String} yesText
2427 * Defaults to 'Yes'.
2430 <div id="cfg-Ext.ux.grid.filter.BooleanFilter-noText"></div>/**
2431 * @cfg {String} noText
2438 * Template method that is to initialize the filter and install required menu items.
2440 init : function (config) {
2443 new Ext.menu.CheckItem({text: this.yesText, group: gId, checked: this.defaultValue === true}),
2444 new Ext.menu.CheckItem({text: this.noText, group: gId, checked: this.defaultValue === false})];
2446 this.menu.add(this.options[0], this.options[1]);
2448 for(var i=0; i<this.options.length; i++){
2449 this.options[i].on('click', this.fireUpdate, this);
2450 this.options[i].on('checkchange', this.fireUpdate, this);
2456 * Template method that is to get and return the value of the filter.
2457 * @return {String} The value of this filter
2459 getValue : function () {
2460 return this.options[0].checked;
2465 * Template method that is to set the value of the filter.
2466 * @param {Object} value The value to set the filter
2468 setValue : function (value) {
2469 this.options[value ? 0 : 1].setChecked(true);
2474 * Template method that is to get and return serialized filter data for
2475 * transmission to the server.
2476 * @return {Object/Array} An object or collection of objects containing
2477 * key value pairs representing the current configuration of the filter.
2479 getSerialArgs : function () {
2480 var args = {type: 'boolean', value: this.getValue()};
2484 <div id="method-Ext.ux.grid.filter.BooleanFilter-validateRecord"></div>/**
2485 * Template method that is to validate the provided Ext.data.Record
2486 * against the filters configuration.
2487 * @param {Ext.data.Record} record The record to validate
2488 * @return {Boolean} true if the record is valid within the bounds
2489 * of the filter, false otherwise.
2491 validateRecord : function (record) {
2492 return record.get(this.dataIndex) == this.getValue();
2495 * @class Ext.ux.grid.filter.DateFilter
2496 * @extends Ext.ux.grid.filter.Filter
2497 * Filter by a configurable Ext.menu.DateMenu
2498 * <p><b><u>Example Usage:</u></b></p>
2500 var filters = new Ext.ux.grid.GridFilters({
2505 dataIndex: 'dateAdded',
2508 dateFormat: 'm/d/Y', // default
2509 beforeText: 'Before', // default
2510 afterText: 'After', // default
2511 onText: 'On', // default
2513 // any DateMenu configs
2516 active: true // default is false
2521 Ext.ux.grid.filter.DateFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
2522 <div id="cfg-Ext.ux.grid.filter.DateFilter-afterText"></div>/**
2523 * @cfg {String} afterText
2524 * Defaults to 'After'.
2526 afterText : 'After',
2527 <div id="cfg-Ext.ux.grid.filter.DateFilter-beforeText"></div>/**
2528 * @cfg {String} beforeText
2529 * Defaults to 'Before'.
2531 beforeText : 'Before',
2532 <div id="cfg-Ext.ux.grid.filter.DateFilter-compareMap"></div>/**
2533 * @cfg {Object} compareMap
2534 * Map for assigning the comparison values used in serialization.
2541 <div id="cfg-Ext.ux.grid.filter.DateFilter-dateFormat"></div>/**
2542 * @cfg {String} dateFormat
2543 * The date format to return when using getValue.
2544 * Defaults to 'm/d/Y'.
2546 dateFormat : 'm/d/Y',
2548 <div id="cfg-Ext.ux.grid.filter.DateFilter-maxDate"></div>/**
2549 * @cfg {Date} maxDate
2550 * Allowable date as passed to the Ext.DatePicker
2551 * Defaults to undefined.
2553 <div id="cfg-Ext.ux.grid.filter.DateFilter-minDate"></div>/**
2554 * @cfg {Date} minDate
2555 * Allowable date as passed to the Ext.DatePicker
2556 * Defaults to undefined.
2558 <div id="cfg-Ext.ux.grid.filter.DateFilter-menuItems"></div>/**
2559 * @cfg {Array} menuItems
2560 * The items to be shown in this menu
2562 * menuItems : ['before', 'after', '-', 'on'],
2565 menuItems : ['before', 'after', '-', 'on'],
2567 <div id="cfg-Ext.ux.grid.filter.DateFilter-menuItemCfgs"></div>/**
2568 * @cfg {Object} menuItemCfgs
2569 * Default configuration options for each menu item
2572 selectOnFocus: true,
2576 <div id="cfg-Ext.ux.grid.filter.DateFilter-onText"></div>/**
2577 * @cfg {String} onText
2582 <div id="cfg-Ext.ux.grid.filter.DateFilter-pickerOpts"></div>/**
2583 * @cfg {Object} pickerOpts
2584 * Configuration options for the date picker associated with each field.
2590 * Template method that is to initialize the filter and install required menu items.
2592 init : function (config) {
2593 var menuCfg, i, len, item, cfg, Cls;
2595 menuCfg = Ext.apply(this.pickerOpts, {
2596 minDate: this.minDate,
2597 maxDate: this.maxDate,
2598 format: this.dateFormat,
2601 select: this.onMenuSelect
2606 for (i = 0, len = this.menuItems.length; i < len; i++) {
2607 item = this.menuItems[i];
2610 itemId: 'range-' + item,
2611 text: this[item + 'Text'],
2612 menu: new Ext.menu.DateMenu(
2613 Ext.apply(menuCfg, {
2619 checkchange: this.onCheckChange
2622 Cls = Ext.menu.CheckItem;
2623 item = this.fields[item] = new Cls(cfg);
2626 this.menu.add(item);
2630 onCheckChange : function () {
2631 this.setActive(this.isActivatable());
2632 this.fireEvent('update', this);
2637 * Handler method called when there is a keyup event on an input
2638 * item of this menu.
2640 onInputKeyUp : function (field, e) {
2642 if (k == e.RETURN && field.isValid()) {
2644 this.menu.hide(true);
2649 <div id="method-Ext.ux.grid.filter.DateFilter-onMenuSelect"></div>/**
2650 * Handler for when the menu for a field fires the 'select' event
2651 * @param {Object} date
2652 * @param {Object} menuItem
2653 * @param {Object} value
2654 * @param {Object} picker
2656 onMenuSelect : function (menuItem, value, picker) {
2657 var fields = this.fields,
2658 field = this.fields[menuItem.itemId];
2660 field.setChecked(true);
2662 if (field == fields.on) {
2663 fields.before.setChecked(false, true);
2664 fields.after.setChecked(false, true);
2666 fields.on.setChecked(false, true);
2667 if (field == fields.after && fields.before.menu.picker.value < value) {
2668 fields.before.setChecked(false, true);
2669 } else if (field == fields.before && fields.after.menu.picker.value > value) {
2670 fields.after.setChecked(false, true);
2673 this.fireEvent('update', this);
2678 * Template method that is to get and return the value of the filter.
2679 * @return {String} The value of this filter
2681 getValue : function () {
2682 var key, result = {};
2683 for (key in this.fields) {
2684 if (this.fields[key].checked) {
2685 result[key] = this.fields[key].menu.picker.getValue();
2693 * Template method that is to set the value of the filter.
2694 * @param {Object} value The value to set the filter
2695 * @param {Boolean} preserve true to preserve the checked status
2696 * of the other fields. Defaults to false, unchecking the
2699 setValue : function (value, preserve) {
2701 for (key in this.fields) {
2703 this.fields[key].menu.picker.setValue(value[key]);
2704 this.fields[key].setChecked(true);
2705 } else if (!preserve) {
2706 this.fields[key].setChecked(false);
2709 this.fireEvent('update', this);
2714 * Template method that is to return <tt>true</tt> if the filter
2715 * has enough configuration information to be activated.
2718 isActivatable : function () {
2720 for (key in this.fields) {
2721 if (this.fields[key].checked) {
2730 * Template method that is to get and return serialized filter data for
2731 * transmission to the server.
2732 * @return {Object/Array} An object or collection of objects containing
2733 * key value pairs representing the current configuration of the filter.
2735 getSerialArgs : function () {
2737 for (var key in this.fields) {
2738 if(this.fields[key].checked){
2741 comparison: this.compareMap[key],
2742 value: this.getFieldValue(key).format(this.dateFormat)
2749 <div id="method-Ext.ux.grid.filter.DateFilter-getFieldValue"></div>/**
2750 * Get and return the date menu picker value
2751 * @param {String} item The field identifier ('before', 'after', 'on')
2752 * @return {Date} Gets the current selected value of the date field
2754 getFieldValue : function(item){
2755 return this.fields[item].menu.picker.getValue();
2758 <div id="method-Ext.ux.grid.filter.DateFilter-getPicker"></div>/**
2759 * Gets the menu picker associated with the passed field
2760 * @param {String} item The field identifier ('before', 'after', 'on')
2761 * @return {Object} The menu picker
2763 getPicker : function(item){
2764 return this.fields[item].menu.picker;
2767 <div id="method-Ext.ux.grid.filter.DateFilter-validateRecord"></div>/**
2768 * Template method that is to validate the provided Ext.data.Record
2769 * against the filters configuration.
2770 * @param {Ext.data.Record} record The record to validate
2771 * @return {Boolean} true if the record is valid within the bounds
2772 * of the filter, false otherwise.
2774 validateRecord : function (record) {
2777 val = record.get(this.dataIndex);
2779 if(!Ext.isDate(val)){
2782 val = val.clearTime(true).getTime();
2784 for (key in this.fields) {
2785 if (this.fields[key].checked) {
2786 pickerValue = this.getFieldValue(key).clearTime(true).getTime();
2787 if (key == 'before' && pickerValue <= val) {
2790 if (key == 'after' && pickerValue >= val) {
2793 if (key == 'on' && pickerValue != val) {
2801 * @class Ext.ux.grid.filter.ListFilter
2802 * @extends Ext.ux.grid.filter.Filter
2803 * <p>List filters are able to be preloaded/backed by an Ext.data.Store to load
2804 * their options the first time they are shown. ListFilter utilizes the
2805 * {@link Ext.ux.menu.ListMenu} component.</p>
2806 * <p>Although not shown here, this class accepts all configuration options
2807 * for {@link Ext.ux.menu.ListMenu}.</p>
2809 * <p><b><u>Example Usage:</u></b></p>
2811 var filters = new Ext.ux.grid.GridFilters({
2817 // options will be used as data to implicitly creates an ArrayStore
2818 options: ['extra small', 'small', 'medium', 'large', 'extra large']
2824 Ext.ux.grid.filter.ListFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
2826 <div id="cfg-Ext.ux.grid.filter.ListFilter-options"></div>/**
2827 * @cfg {Array} options
2828 * <p><code>data</code> to be used to implicitly create a data store
2829 * to back this list when the data source is <b>local</b>. If the
2830 * data for the list is remote, use the <code>{@link #store}</code>
2831 * config instead.</p>
2832 * <br><p>Each item within the provided array may be in one of the
2833 * following formats:</p>
2834 * <div class="mdetail-params"><ul>
2835 * <li><b>Array</b> :
2838 [11, 'extra small'],
2846 * <li><b>Object</b> :
2848 labelField: 'name', // override default of 'text'
2850 {id: 11, name:'extra small'},
2851 {id: 18, name:'small'},
2852 {id: 22, name:'medium'},
2853 {id: 35, name:'large'},
2854 {id: 44, name:'extra large'}
2858 * <li><b>String</b> :
2860 * options: ['extra small', 'small', 'medium', 'large', 'extra large']
2864 <div id="cfg-Ext.ux.grid.filter.ListFilter-phpMode"></div>/**
2865 * @cfg {Boolean} phpMode
2866 * <p>Adjust the format of this filter. Defaults to false.</p>
2867 * <br><p>When GridFilters <code>@cfg encode = false</code> (default):</p>
2869 // phpMode == false (default):
2870 filter[0][data][type] list
2871 filter[0][data][value] value1
2872 filter[0][data][value] value2
2873 filter[0][field] prod
2876 filter[0][data][type] list
2877 filter[0][data][value] value1, value2
2878 filter[0][field] prod
2880 * When GridFilters <code>@cfg encode = true</code>:
2882 // phpMode == false (default):
2883 filter : [{"type":"list","value":["small","medium"],"field":"size"}]
2886 filter : [{"type":"list","value":"small,medium","field":"size"}]
2890 <div id="cfg-Ext.ux.grid.filter.ListFilter-store"></div>/**
2891 * @cfg {Ext.data.Store} store
2892 * The {@link Ext.data.Store} this list should use as its data source
2893 * when the data source is <b>remote</b>. If the data for the list
2894 * is local, use the <code>{@link #options}</code> config instead.
2899 * Template method that is to initialize the filter and install required menu items.
2900 * @param {Object} config
2902 init : function (config) {
2903 this.dt = new Ext.util.DelayedTask(this.fireUpdate, this);
2905 // if a menu already existed, do clean up first
2907 this.menu.destroy();
2909 this.menu = new Ext.ux.menu.ListMenu(config);
2910 this.menu.on('checkchange', this.onCheckChange, this);
2915 * Template method that is to get and return the value of the filter.
2916 * @return {String} The value of this filter
2918 getValue : function () {
2919 return this.menu.getSelected();
2923 * Template method that is to set the value of the filter.
2924 * @param {Object} value The value to set the filter
2926 setValue : function (value) {
2927 this.menu.setSelected(value);
2928 this.fireEvent('update', this);
2933 * Template method that is to return <tt>true</tt> if the filter
2934 * has enough configuration information to be activated.
2937 isActivatable : function () {
2938 return this.getValue().length > 0;
2943 * Template method that is to get and return serialized filter data for
2944 * transmission to the server.
2945 * @return {Object/Array} An object or collection of objects containing
2946 * key value pairs representing the current configuration of the filter.
2948 getSerialArgs : function () {
2949 var args = {type: 'list', value: this.phpMode ? this.getValue().join(',') : this.getValue()};
2954 onCheckChange : function(){
2955 this.dt.delay(this.updateBuffer);
2959 <div id="method-Ext.ux.grid.filter.ListFilter-validateRecord"></div>/**
2960 * Template method that is to validate the provided Ext.data.Record
2961 * against the filters configuration.
2962 * @param {Ext.data.Record} record The record to validate
2963 * @return {Boolean} true if the record is valid within the bounds
2964 * of the filter, false otherwise.
2966 validateRecord : function (record) {
2967 return this.getValue().indexOf(record.get(this.dataIndex)) > -1;
2970 * @class Ext.ux.grid.filter.NumericFilter
2971 * @extends Ext.ux.grid.filter.Filter
2972 * Filters using an Ext.ux.menu.RangeMenu.
2973 * <p><b><u>Example Usage:</u></b></p>
2975 var filters = new Ext.ux.grid.GridFilters({
2984 Ext.ux.grid.filter.NumericFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
2986 <div id="cfg-Ext.ux.grid.filter.NumericFilter-fieldCls"></div>/**
2987 * @cfg {Object} fieldCls
2988 * The Class to use to construct each field item within this menu
2990 * fieldCls : Ext.form.NumberField
2993 fieldCls : Ext.form.NumberField,
2994 <div id="cfg-Ext.ux.grid.filter.NumericFilter-fieldCfg"></div>/**
2995 * @cfg {Object} fieldCfg
2996 * The default configuration options for any field item unless superseded
2997 * by the <code>{@link #fields}</code> configuration.
3008 <div id="cfg-Ext.ux.grid.filter.NumericFilter-fields"></div>/**
3009 * @cfg {Object} fields
3010 * The field items may be configured individually
3011 * Defaults to <tt>undefined</tt>.
3015 gt: { // override fieldCfg options
3017 fieldCls: Ext.ux.form.CustomNumberField // to override default {@link #fieldCls}
3022 <div id="cfg-Ext.ux.grid.filter.NumericFilter-iconCls"></div>/**
3023 * @cfg {Object} iconCls
3024 * The iconCls to be applied to each comparator field item.
3027 gt : 'ux-rangemenu-gt',
3028 lt : 'ux-rangemenu-lt',
3029 eq : 'ux-rangemenu-eq'
3034 gt : 'ux-rangemenu-gt',
3035 lt : 'ux-rangemenu-lt',
3036 eq : 'ux-rangemenu-eq'
3039 <div id="cfg-Ext.ux.grid.filter.NumericFilter-menuItemCfgs"></div>/**
3040 * @cfg {Object} menuItemCfgs
3041 * Default configuration options for each menu item
3044 emptyText: 'Enter Filter Text...',
3045 selectOnFocus: true,
3051 emptyText: 'Enter Filter Text...',
3052 selectOnFocus: true,
3056 <div id="cfg-Ext.ux.grid.filter.NumericFilter-menuItems"></div>/**
3057 * @cfg {Array} menuItems
3058 * The items to be shown in this menu. Items are added to the menu
3059 * according to their position within this array. Defaults to:<pre>
3060 * menuItems : ['lt','gt','-','eq']
3063 menuItems : ['lt', 'gt', '-', 'eq'],
3067 * Template method that is to initialize the filter and install required menu items.
3069 init : function (config) {
3070 // if a menu already existed, do clean up first
3072 this.menu.destroy();
3074 this.menu = new Ext.ux.menu.RangeMenu(Ext.apply(config, {
3075 // pass along filter configs to the menu
3076 fieldCfg : this.fieldCfg || {},
3077 fieldCls : this.fieldCls,
3078 fields : this.fields || {},
3079 iconCls: this.iconCls,
3080 menuItemCfgs: this.menuItemCfgs,
3081 menuItems: this.menuItems,
3082 updateBuffer: this.updateBuffer
3084 // relay the event fired by the menu
3085 this.menu.on('update', this.fireUpdate, this);
3090 * Template method that is to get and return the value of the filter.
3091 * @return {String} The value of this filter
3093 getValue : function () {
3094 return this.menu.getValue();
3099 * Template method that is to set the value of the filter.
3100 * @param {Object} value The value to set the filter
3102 setValue : function (value) {
3103 this.menu.setValue(value);
3108 * Template method that is to return <tt>true</tt> if the filter
3109 * has enough configuration information to be activated.
3112 isActivatable : function () {
3113 var values = this.getValue();
3114 for (key in values) {
3115 if (values[key] !== undefined) {
3124 * Template method that is to get and return serialized filter data for
3125 * transmission to the server.
3126 * @return {Object/Array} An object or collection of objects containing
3127 * key value pairs representing the current configuration of the filter.
3129 getSerialArgs : function () {
3132 values = this.menu.getValue();
3133 for (key in values) {
3143 <div id="method-Ext.ux.grid.filter.NumericFilter-validateRecord"></div>/**
3144 * Template method that is to validate the provided Ext.data.Record
3145 * against the filters configuration.
3146 * @param {Ext.data.Record} record The record to validate
3147 * @return {Boolean} true if the record is valid within the bounds
3148 * of the filter, false otherwise.
3150 validateRecord : function (record) {
3151 var val = record.get(this.dataIndex),
3152 values = this.getValue();
3153 if (values.eq !== undefined && val != values.eq) {
3156 if (values.lt !== undefined && val >= values.lt) {
3159 if (values.gt !== undefined && val <= values.gt) {
3165 * @class Ext.ux.grid.filter.StringFilter
3166 * @extends Ext.ux.grid.filter.Filter
3167 * Filter by a configurable Ext.form.TextField
3168 * <p><b><u>Example Usage:</u></b></p>
3170 var filters = new Ext.ux.grid.GridFilters({
3179 active: true, // default is false
3180 iconCls: 'ux-gridfilter-text-icon' // default
3181 // any Ext.form.TextField configs accepted
3186 Ext.ux.grid.filter.StringFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
3188 <div id="cfg-Ext.ux.grid.filter.StringFilter-iconCls"></div>/**
3189 * @cfg {String} iconCls
3190 * The iconCls to be applied to the menu item.
3191 * Defaults to <tt>'ux-gridfilter-text-icon'</tt>.
3193 iconCls : 'ux-gridfilter-text-icon',
3195 emptyText: 'Enter Filter Text...',
3196 selectOnFocus: true,
3201 * Template method that is to initialize the filter and install required menu items.
3203 init : function (config) {
3204 Ext.applyIf(config, {
3205 enableKeyEvents: true,
3206 iconCls: this.iconCls,
3209 keyup: this.onInputKeyUp
3213 this.inputItem = new Ext.form.TextField(config);
3214 this.menu.add(this.inputItem);
3215 this.updateTask = new Ext.util.DelayedTask(this.fireUpdate, this);
3220 * Template method that is to get and return the value of the filter.
3221 * @return {String} The value of this filter
3223 getValue : function () {
3224 return this.inputItem.getValue();
3229 * Template method that is to set the value of the filter.
3230 * @param {Object} value The value to set the filter
3232 setValue : function (value) {
3233 this.inputItem.setValue(value);
3234 this.fireEvent('update', this);
3239 * Template method that is to return <tt>true</tt> if the filter
3240 * has enough configuration information to be activated.
3243 isActivatable : function () {
3244 return this.inputItem.getValue().length > 0;
3249 * Template method that is to get and return serialized filter data for
3250 * transmission to the server.
3251 * @return {Object/Array} An object or collection of objects containing
3252 * key value pairs representing the current configuration of the filter.
3254 getSerialArgs : function () {
3255 return {type: 'string', value: this.getValue()};
3258 <div id="method-Ext.ux.grid.filter.StringFilter-validateRecord"></div>/**
3259 * Template method that is to validate the provided Ext.data.Record
3260 * against the filters configuration.
3261 * @param {Ext.data.Record} record The record to validate
3262 * @return {Boolean} true if the record is valid within the bounds
3263 * of the filter, false otherwise.
3265 validateRecord : function (record) {
3266 var val = record.get(this.dataIndex);
3268 if(typeof val != 'string') {
3269 return (this.getValue().length === 0);
3272 return val.toLowerCase().indexOf(this.getValue().toLowerCase()) > -1;
3277 * Handler method called when there is a keyup event on this.inputItem
3279 onInputKeyUp : function (field, e) {
3281 if (k == e.RETURN && field.isValid()) {
3283 this.menu.hide(true);
3286 // restart the timer
3287 this.updateTask.delay(this.updateBuffer);
3290 Ext.namespace('Ext.ux.menu');
3293 * @class Ext.ux.menu.ListMenu
3294 * @extends Ext.menu.Menu
3295 * This is a supporting class for {@link Ext.ux.grid.filter.ListFilter}.
3296 * Although not listed as configuration options for this class, this class
3297 * also accepts all configuration options from {@link Ext.ux.grid.filter.ListFilter}.
3299 Ext.ux.menu.ListMenu = Ext.extend(Ext.menu.Menu, {
3300 <div id="cfg-Ext.ux.menu.ListMenu-labelField"></div>/**
3301 * @cfg {String} labelField
3302 * Defaults to 'text'.
3304 labelField : 'text',
3305 <div id="cfg-Ext.ux.menu.ListMenu-paramPrefix"></div>/**
3306 * @cfg {String} paramPrefix
3307 * Defaults to 'Loading...'.
3309 loadingText : 'Loading...',
3310 <div id="cfg-Ext.ux.menu.ListMenu-loadOnShow"></div>/**
3311 * @cfg {Boolean} loadOnShow
3315 <div id="cfg-Ext.ux.menu.ListMenu-single"></div>/**
3316 * @cfg {Boolean} single
3317 * Specify true to group all items in this list into a single-select
3318 * radio button group. Defaults to false.
3322 constructor : function (cfg) {
3325 <div id="event-Ext.ux.menu.ListMenu-checkchange"></div>/**
3326 * @event checkchange
3327 * Fires when there is a change in checked items from this list
3328 * @param {Object} item Ext.menu.CheckItem
3329 * @param {Object} checked The checked value that was set
3334 Ext.ux.menu.ListMenu.superclass.constructor.call(this, cfg = cfg || {});
3336 if(!cfg.store && cfg.options){
3338 for(var i=0, len=cfg.options.length; i<len; i++){
3339 var value = cfg.options[i];
3340 switch(Ext.type(value)){
3341 case 'array': options.push(value); break;
3342 case 'object': options.push([value.id, value[this.labelField]]); break;
3343 case 'string': options.push([value, value]); break;
3347 this.store = new Ext.data.Store({
3348 reader: new Ext.data.ArrayReader({id: 0}, ['id', this.labelField]),
3351 'load': this.onLoad,
3357 this.add({text: this.loadingText, iconCls: 'loading-indicator'});
3358 this.store.on('load', this.onLoad, this);
3362 destroy : function () {
3364 this.store.destroy();
3366 Ext.ux.menu.ListMenu.superclass.destroy.call(this);
3369 <div id="method-Ext.ux.menu.ListMenu-show"></div>/**
3370 * Lists will initially show a 'loading' item while the data is retrieved from the store.
3371 * In some cases the loaded data will result in a list that goes off the screen to the
3372 * right (as placement calculations were done with the loading item). This adapter will
3373 * allow show to be called with no arguments to show with the previous arguments and
3374 * thus recalculate the width and potentially hang the menu from the left.
3376 show : function () {
3377 var lastArgs = null;
3379 if(arguments.length === 0){
3380 Ext.ux.menu.ListMenu.superclass.show.apply(this, lastArgs);
3382 lastArgs = arguments;
3383 if (this.loadOnShow && !this.loaded) {
3386 Ext.ux.menu.ListMenu.superclass.show.apply(this, arguments);
3392 onLoad : function (store, records) {
3393 var visible = this.isVisible();
3396 this.removeAll(true);
3398 var gid = this.single ? Ext.id() : null;
3399 for(var i=0, len=records.length; i<len; i++){
3400 var item = new Ext.menu.CheckItem({
3401 text: records[i].get(this.labelField),
3403 checked: this.selected.indexOf(records[i].id) > -1,
3404 hideOnClick: false});
3406 item.itemId = records[i].id;
3407 item.on('checkchange', this.checkChange, this);
3417 this.fireEvent('load', this, records);
3420 <div id="method-Ext.ux.menu.ListMenu-getSelected"></div>/**
3421 * Get the selected items.
3422 * @return {Array} selected
3424 getSelected : function () {
3425 return this.selected;
3429 setSelected : function (value) {
3430 value = this.selected = [].concat(value);
3433 this.items.each(function(item){
3434 item.setChecked(false, true);
3435 for (var i = 0, len = value.length; i < len; i++) {
3436 if (item.itemId == value[i]) {
3437 item.setChecked(true, true);
3444 <div id="method-Ext.ux.menu.ListMenu-checkChange"></div>/**
3445 * Handler for the 'checkchange' event from an check item in this menu
3446 * @param {Object} item Ext.menu.CheckItem
3447 * @param {Object} checked The checked value that was set
3449 checkChange : function (item, checked) {
3451 this.items.each(function(item){
3453 value.push(item.itemId);
3456 this.selected = value;
3458 this.fireEvent('checkchange', item, checked);
3460 });Ext.ns('Ext.ux.menu');
3463 * @class Ext.ux.menu.RangeMenu
3464 * @extends Ext.menu.Menu
3465 * Custom implementation of Ext.menu.Menu that has preconfigured
3466 * items for gt, lt, eq.
3467 * <p><b><u>Example Usage:</u></b></p>
3472 Ext.ux.menu.RangeMenu = Ext.extend(Ext.menu.Menu, {
3474 constructor : function (config) {
3476 Ext.ux.menu.RangeMenu.superclass.constructor.call(this, config);
3479 <div id="event-Ext.ux.menu.RangeMenu-update"></div>/**
3481 * Fires when a filter configuration has changed
3482 * @param {Ext.ux.grid.filter.Filter} this The filter object.
3487 this.updateTask = new Ext.util.DelayedTask(this.fireUpdate, this);
3489 var i, len, item, cfg, Cls;
3491 for (i = 0, len = this.menuItems.length; i < len; i++) {
3492 item = this.menuItems[i];
3496 itemId: 'range-' + item,
3497 enableKeyEvents: true,
3498 iconCls: this.iconCls[item] || 'no-icon',
3501 keyup: this.onInputKeyUp
3507 Ext.applyIf(this.fields[item] || {}, this.fieldCfg[item]),
3508 // configurable defaults
3511 Cls = cfg.fieldCls || this.fieldCls;
3512 item = this.fields[item] = new Cls(cfg);
3520 * called by this.updateTask
3522 fireUpdate : function () {
3523 this.fireEvent('update', this);
3526 <div id="method-Ext.ux.menu.RangeMenu-getValue"></div>/**
3527 * Get and return the value of the filter.
3528 * @return {String} The value of this filter
3530 getValue : function () {
3531 var result = {}, key, field;
3532 for (key in this.fields) {
3533 field = this.fields[key];
3534 if (field.isValid() && String(field.getValue()).length > 0) {
3535 result[key] = field.getValue();
3541 <div id="method-Ext.ux.menu.RangeMenu-setValue"></div>/**
3542 * Set the value of this menu and fires the 'update' event.
3543 * @param {Object} data The data to assign to this menu
3545 setValue : function (data) {
3547 for (key in this.fields) {
3548 this.fields[key].setValue(data[key] !== undefined ? data[key] : '');
3550 this.fireEvent('update', this);
3555 * Handler method called when there is a keyup event on an input
3556 * item of this menu.
3558 onInputKeyUp : function (field, e) {
3560 if (k == e.RETURN && field.isValid()) {
3566 if (field == this.fields.eq) {
3567 if (this.fields.gt) {
3568 this.fields.gt.setValue(null);
3570 if (this.fields.lt) {
3571 this.fields.lt.setValue(null);
3575 this.fields.eq.setValue(null);
3578 // restart the timer
3579 this.updateTask.delay(this.updateBuffer);
3582 Ext.ns('Ext.ux.grid');
3585 * @class Ext.ux.grid.GroupSummary
3586 * @extends Ext.util.Observable
3587 * A GridPanel plugin that enables dynamic column calculations and a dynamically
3588 * updated grouped summary row.
3590 Ext.ux.grid.GroupSummary = Ext.extend(Ext.util.Observable, {
3591 <div id="cfg-Ext.ux.grid.GroupSummary-summaryRenderer"></div>/**
3592 * @cfg {Function} summaryRenderer Renderer example:<pre><code>
3593 summaryRenderer: function(v, params, data){
3594 return ((v === 0 || v > 1) ? '(' + v +' Tasks)' : '(1 Task)');
3598 <div id="cfg-Ext.ux.grid.GroupSummary-summaryType"></div>/**
3599 * @cfg {String} summaryType (Optional) The type of
3600 * calculation to be used for the column. For options available see
3601 * {@link #Calculations}.
3604 constructor : function(config){
3605 Ext.apply(this, config);
3606 Ext.ux.grid.GroupSummary.superclass.constructor.call(this);
3608 init : function(grid){
3610 var v = this.view = grid.getView();
3611 v.doGroupEnd = this.doGroupEnd.createDelegate(this);
3613 v.afterMethod('onColumnWidthUpdated', this.doWidth, this);
3614 v.afterMethod('onAllColumnWidthsUpdated', this.doAllWidths, this);
3615 v.afterMethod('onColumnHiddenUpdated', this.doHidden, this);
3616 v.afterMethod('onUpdate', this.doUpdate, this);
3617 v.afterMethod('onRemove', this.doRemove, this);
3620 this.rowTpl = new Ext.Template(
3621 '<div class="x-grid3-summary-row" style="{tstyle}">',
3622 '<table class="x-grid3-summary-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
3623 '<tbody><tr>{cells}</tr></tbody>',
3626 this.rowTpl.disableFormats = true;
3628 this.rowTpl.compile();
3631 this.cellTpl = new Ext.Template(
3632 '<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} {css}" style="{style}">',
3633 '<div class="x-grid3-cell-inner x-grid3-col-{id}" unselectable="on">{value}</div>',
3636 this.cellTpl.disableFormats = true;
3638 this.cellTpl.compile();
3641 <div id="method-Ext.ux.grid.GroupSummary-toggleSummaries"></div>/**
3642 * Toggle the display of the summary row on/off
3643 * @param {Boolean} visible <tt>true</tt> to show the summary, <tt>false</tt> to hide the summary.
3645 toggleSummaries : function(visible){
3646 var el = this.grid.getGridEl();
3648 if(visible === undefined){
3649 visible = el.hasClass('x-grid-hide-summary');
3651 el[visible ? 'removeClass' : 'addClass']('x-grid-hide-summary');
3655 renderSummary : function(o, cs){
3656 cs = cs || this.view.getColumnData();
3657 var cfg = this.grid.getColumnModel().config,
3658 buf = [], c, p = {}, cf, last = cs.length-1;
3659 for(var i = 0, len = cs.length; i < len; i++){
3664 p.css = i == 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
3665 if(cf.summaryType || cf.summaryRenderer){
3666 p.value = (cf.summaryRenderer || c.renderer)(o.data[c.name], p, o);
3670 if(p.value == undefined || p.value === "") p.value = " ";
3671 buf[buf.length] = this.cellTpl.apply(p);
3674 return this.rowTpl.apply({
3675 tstyle: 'width:'+this.view.getTotalWidth()+';',
3682 * @param {Object} rs
3683 * @param {Object} cs
3685 calculate : function(rs, cs){
3686 var data = {}, r, c, cfg = this.grid.getColumnModel().config, cf;
3687 for(var j = 0, jlen = rs.length; j < jlen; j++){
3689 for(var i = 0, len = cs.length; i < len; i++){
3693 data[c.name] = Ext.ux.grid.GroupSummary.Calculations[cf.summaryType](data[c.name] || 0, r, c.name, data);
3700 doGroupEnd : function(buf, g, cs, ds, colCount){
3701 var data = this.calculate(g.rs, cs);
3702 buf.push('</div>', this.renderSummary({data: data}, cs), '</div>');
3705 doWidth : function(col, w, tw){
3706 if(!this.isGrouped()){
3709 var gs = this.view.getGroups(),
3713 for(; i < len; ++i){
3714 s = gs[i].childNodes[2];
3716 s.firstChild.style.width = tw;
3717 s.firstChild.rows[0].childNodes[col].style.width = w;
3721 doAllWidths : function(ws, tw){
3722 if(!this.isGrouped()){
3725 var gs = this.view.getGroups(),
3733 for(; i < len; i++){
3734 s = gs[i].childNodes[2];
3736 s.firstChild.style.width = tw;
3737 cells = s.firstChild.rows[0].childNodes;
3738 for(j = 0; j < wlen; j++){
3739 cells[j].style.width = ws[j];
3744 doHidden : function(col, hidden, tw){
3745 if(!this.isGrouped()){
3748 var gs = this.view.getGroups(),
3752 display = hidden ? 'none' : '';
3753 for(; i < len; i++){
3754 s = gs[i].childNodes[2];
3756 s.firstChild.style.width = tw;
3757 s.firstChild.rows[0].childNodes[col].style.display = display;
3761 isGrouped : function(){
3762 return !Ext.isEmpty(this.grid.getStore().groupField);
3765 // Note: requires that all (or the first) record in the
3766 // group share the same group value. Returns false if the group
3767 // could not be found.
3768 refreshSummary : function(groupValue){
3769 return this.refreshSummaryById(this.view.getGroupId(groupValue));
3772 getSummaryNode : function(gid){
3773 var g = Ext.fly(gid, '_gsummary');
3775 return g.down('.x-grid3-summary-row', true);
3780 refreshSummaryById : function(gid){
3781 var g = Ext.getDom(gid);
3786 this.grid.getStore().each(function(r){
3787 if(r._groupId == gid){
3791 var cs = this.view.getColumnData(),
3792 data = this.calculate(rs, cs),
3793 markup = this.renderSummary({data: data}, cs),
3794 existing = this.getSummaryNode(gid);
3797 g.removeChild(existing);
3799 Ext.DomHelper.append(g, markup);
3803 doUpdate : function(ds, record){
3804 this.refreshSummaryById(record._groupId);
3807 doRemove : function(ds, record, index, isUpdate){
3809 this.refreshSummaryById(record._groupId);
3813 <div id="method-Ext.ux.grid.GroupSummary-showSummaryMsg"></div>/**
3814 * Show a message in the summary row.
3816 grid.on('afteredit', function(){
3817 var groupValue = 'Ext Forms: Field Anchoring';
3818 summary.showSummaryMsg(groupValue, 'Updating Summary...');
3821 * @param {String} groupValue
3822 * @param {String} msg Text to use as innerHTML for the summary row.
3824 showSummaryMsg : function(groupValue, msg){
3825 var gid = this.view.getGroupId(groupValue),
3826 node = this.getSummaryNode(gid);
3828 node.innerHTML = '<div class="x-grid3-summary-msg">' + msg + '</div>';
3834 Ext.grid.GroupSummary = Ext.ux.grid.GroupSummary;
3837 <div id="prop-Ext.ux.grid.GroupSummary-Calculations"></div>/**
3838 * Calculation types for summary row:</p><div class="mdetail-params"><ul>
3839 * <li><b><tt>sum</tt></b> : <div class="sub-desc"></div></li>
3840 * <li><b><tt>count</tt></b> : <div class="sub-desc"></div></li>
3841 * <li><b><tt>max</tt></b> : <div class="sub-desc"></div></li>
3842 * <li><b><tt>min</tt></b> : <div class="sub-desc"></div></li>
3843 * <li><b><tt>average</tt></b> : <div class="sub-desc"></div></li>
3845 * <p>Custom calculations may be implemented. An example of
3846 * custom <code>summaryType=totalCost</code>:</p><pre><code>
3847 // define a custom summary function
3848 Ext.ux.grid.GroupSummary.Calculations['totalCost'] = function(v, record, field){
3849 return v + (record.data.estimate * record.data.rate);
3852 * @property Calculations
3855 Ext.ux.grid.GroupSummary.Calculations = {
3856 'sum' : function(v, record, field){
3857 return v + (record.data[field]||0);
3860 'count' : function(v, record, field, data){
3861 return data[field+'count'] ? ++data[field+'count'] : (data[field+'count'] = 1);
3864 'max' : function(v, record, field, data){
3865 var v = record.data[field];
3866 var max = data[field+'max'] === undefined ? (data[field+'max'] = v) : data[field+'max'];
3867 return v > max ? (data[field+'max'] = v) : max;
3870 'min' : function(v, record, field, data){
3871 var v = record.data[field];
3872 var min = data[field+'min'] === undefined ? (data[field+'min'] = v) : data[field+'min'];
3873 return v < min ? (data[field+'min'] = v) : min;
3876 'average' : function(v, record, field, data){
3877 var c = data[field+'count'] ? ++data[field+'count'] : (data[field+'count'] = 1);
3878 var t = (data[field+'total'] = ((data[field+'total']||0) + (record.data[field]||0)));
3879 return t === 0 ? 0 : t / c;
3882 Ext.grid.GroupSummary.Calculations = Ext.ux.grid.GroupSummary.Calculations;
3885 * @class Ext.ux.grid.HybridSummary
3886 * @extends Ext.ux.grid.GroupSummary
3887 * Adds capability to specify the summary data for the group via json as illustrated here:
3892 projectId: 100, project: 'House',
3893 taskId: 112, description: 'Paint',
3894 estimate: 6, rate: 150,
3902 description: 14, estimate: 9,
3903 rate: 99, due: new Date(2009, 6, 29),
3911 Ext.ux.grid.HybridSummary = Ext.extend(Ext.ux.grid.GroupSummary, {
3914 * @param {Object} rs
3915 * @param {Object} cs
3917 calculate : function(rs, cs){
3918 var gcol = this.view.getGroupField(),
3919 gvalue = rs[0].data[gcol],
3920 gdata = this.getSummaryData(gvalue);
3921 return gdata || Ext.ux.grid.HybridSummary.superclass.calculate.call(this, rs, cs);
3924 <div id="method-Ext.ux.grid.HybridSummary-updateSummaryData"></div>/**
3926 grid.on('afteredit', function(){
3927 var groupValue = 'Ext Forms: Field Anchoring';
3928 summary.showSummaryMsg(groupValue, 'Updating Summary...');
3929 setTimeout(function(){ // simulate server call
3930 // HybridSummary class implements updateSummaryData
3931 summary.updateSummaryData(groupValue,
3932 // create data object based on configured dataIndex
3933 {description: 22, estimate: 888, rate: 888, due: new Date(), cost: 8});
3937 * @param {String} groupValue
3938 * @param {Object} data data object
3939 * @param {Boolean} skipRefresh (Optional) Defaults to false
3941 updateSummaryData : function(groupValue, data, skipRefresh){
3942 var json = this.grid.getStore().reader.jsonData;
3943 if(!json.summaryData){
3944 json.summaryData = {};
3946 json.summaryData[groupValue] = data;
3948 this.refreshSummary(groupValue);
3952 <div id="method-Ext.ux.grid.HybridSummary-getSummaryData"></div>/**
3953 * Returns the summaryData for the specified groupValue or null.
3954 * @param {String} groupValue
3955 * @return {Object} summaryData
3957 getSummaryData : function(groupValue){
3958 var reader = this.grid.getStore().reader,
3959 json = reader.jsonData,
3960 fields = reader.recordType.prototype.fields,
3963 if(json && json.summaryData){
3964 v = json.summaryData[groupValue];
3966 return reader.extractValues(v, fields.items, fields.length);
3974 Ext.grid.HybridSummary = Ext.ux.grid.HybridSummary;
3975 Ext.ux.GroupTab = Ext.extend(Ext.Container, {
3980 deferredRender: true,
3986 headerAsText: false,
3992 initComponent: function(config){
3993 Ext.apply(this, config);
3996 Ext.ux.GroupTab.superclass.initComponent.call(this);
3998 this.addEvents('activate', 'deactivate', 'changemainitem', 'beforetabchange', 'tabchange');
4000 this.setLayout(new Ext.layout.CardLayout({
4001 deferredRender: this.deferredRender
4005 this.stack = Ext.TabPanel.AccessStack();
4010 this.on('beforerender', function(){
4011 this.groupEl = this.ownerCt.getGroupEl(this);
4014 this.on('add', this.onAdd, this, {
4017 this.on('remove', this.onRemove, this, {
4021 if (this.mainItem !== undefined) {
4022 var item = (typeof this.mainItem == 'object') ? this.mainItem : this.items.get(this.mainItem);
4023 delete this.mainItem;
4024 this.setMainItem(item);
4028 <div id="method-Ext.ux.grid.HybridSummary-setActiveTab"></div>/**
4029 * Sets the specified tab as the active tab. This method fires the {@link #beforetabchange} event which
4030 * can return false to cancel the tab change.
4031 * @param {String/Panel} tab The id or tab Panel to activate
4033 setActiveTab : function(item){
4034 item = this.getComponent(item);
4039 this.activeTab = item;
4042 if(this.activeTab != item && this.fireEvent('beforetabchange', this, item, this.activeTab) !== false){
4043 if(this.activeTab && this.activeTab != this.mainItem){
4044 var oldEl = this.getTabEl(this.activeTab);
4046 Ext.fly(oldEl).removeClass('x-grouptabs-strip-active');
4049 var el = this.getTabEl(item);
4050 Ext.fly(el).addClass('x-grouptabs-strip-active');
4051 this.activeTab = item;
4052 this.stack.add(item);
4054 this.layout.setActiveItem(item);
4055 if(this.layoutOnTabChange && item.doLayout){
4059 this.scrollToTab(item, this.animScroll);
4062 this.fireEvent('tabchange', this, item);
4068 getTabEl: function(item){
4069 if (item == this.mainItem) {
4070 return this.groupEl;
4072 return Ext.TabPanel.prototype.getTabEl.call(this, item);
4075 onRender: function(ct, position){
4076 Ext.ux.GroupTab.superclass.onRender.call(this, ct, position);
4078 this.strip = Ext.fly(this.groupEl).createChild({
4080 cls: 'x-grouptabs-sub'
4083 this.tooltip = new Ext.ToolTip({
4084 target: this.groupEl,
4085 delegate: 'a.x-grouptabs-text',
4087 renderTo: document.body,
4089 beforeshow: function(tip) {
4090 var item = (tip.triggerElement.parentNode === this.mainItem.tabEl)
4092 : this.findById(tip.triggerElement.parentNode.id.split(this.idDelimiter)[1]);
4097 tip.body.dom.innerHTML = item.tabTip;
4103 if (!this.itemTpl) {
4104 var tt = new Ext.Template('<li class="{cls}" id="{id}">', '<a onclick="return false;" class="x-grouptabs-text {iconCls}">{text}</a>', '</li>');
4105 tt.disableFormats = true;
4107 Ext.ux.GroupTab.prototype.itemTpl = tt;
4110 this.items.each(this.initTab, this);
4113 afterRender: function(){
4114 Ext.ux.GroupTab.superclass.afterRender.call(this);
4116 if (this.activeTab !== undefined) {
4117 var item = (typeof this.activeTab == 'object') ? this.activeTab : this.items.get(this.activeTab);
4118 delete this.activeTab;
4119 this.setActiveTab(item);
4124 initTab: function(item, index){
4125 var before = this.strip.dom.childNodes[index];
4126 var p = Ext.TabPanel.prototype.getTemplateArgs.call(this, item);
4128 if (item === this.mainItem) {
4129 item.tabEl = this.groupEl;
4130 p.cls += ' x-grouptabs-main-item';
4133 var el = before ? this.itemTpl.insertBefore(before, p) : this.itemTpl.append(this.strip, p);
4135 item.tabEl = item.tabEl || el;
4137 item.on('disable', this.onItemDisabled, this);
4138 item.on('enable', this.onItemEnabled, this);
4139 item.on('titlechange', this.onItemTitleChanged, this);
4140 item.on('iconchange', this.onItemIconChanged, this);
4141 item.on('beforeshow', this.onBeforeShowItem, this);
4144 setMainItem: function(item){
4145 item = this.getComponent(item);
4146 if (!item || this.fireEvent('changemainitem', this, item, this.mainItem) === false) {
4150 this.mainItem = item;
4153 getMainItem: function(){
4154 return this.mainItem || null;
4158 onBeforeShowItem: function(item){
4159 if (item != this.activeTab) {
4160 this.setActiveTab(item);
4166 onAdd: function(gt, item, index){
4167 if (this.rendered) {
4168 this.initTab.call(this, item, index);
4173 onRemove: function(tp, item){
4174 Ext.destroy(Ext.get(this.getTabEl(item)));
4175 this.stack.remove(item);
4176 item.un('disable', this.onItemDisabled, this);
4177 item.un('enable', this.onItemEnabled, this);
4178 item.un('titlechange', this.onItemTitleChanged, this);
4179 item.un('iconchange', this.onItemIconChanged, this);
4180 item.un('beforeshow', this.onBeforeShowItem, this);
4181 if (item == this.activeTab) {
4182 var next = this.stack.next();
4184 this.setActiveTab(next);
4186 else if (this.items.getCount() > 0) {
4187 this.setActiveTab(0);
4190 this.activeTab = null;
4196 onBeforeAdd: function(item){
4197 var existing = item.events ? (this.items.containsKey(item.getItemId()) ? item : null) : this.items.get(item);
4199 this.setActiveTab(item);
4202 Ext.TabPanel.superclass.onBeforeAdd.apply(this, arguments);
4203 var es = item.elements;
4204 item.elements = es ? es.replace(',header', '') : es;
4205 item.border = (item.border === true);
4209 onItemDisabled: Ext.TabPanel.prototype.onItemDisabled,
4210 onItemEnabled: Ext.TabPanel.prototype.onItemEnabled,
4213 onItemTitleChanged: function(item){
4214 var el = this.getTabEl(item);
4216 Ext.fly(el).child('a.x-grouptabs-text', true).innerHTML = item.title;
4221 onItemIconChanged: function(item, iconCls, oldCls){
4222 var el = this.getTabEl(item);
4224 Ext.fly(el).child('a.x-grouptabs-text').replaceClass(oldCls, iconCls);
4228 beforeDestroy: function(){
4229 Ext.TabPanel.prototype.beforeDestroy.call(this);
4230 this.tooltip.destroy();
4234 Ext.reg('grouptab', Ext.ux.GroupTab);
4237 Ext.ux.GroupTabPanel = Ext.extend(Ext.TabPanel, {
4238 tabPosition: 'left',
4240 alternateColor: false,
4242 alternateCls: 'x-grouptabs-panel-alt',
4244 defaultType: 'grouptab',
4246 deferredRender: false,
4250 initComponent: function(){
4251 Ext.ux.GroupTabPanel.superclass.initComponent.call(this);
4254 'beforegroupchange',
4257 this.elements = 'body,header';
4258 this.stripTarget = 'header';
4260 this.tabPosition = this.tabPosition == 'right' ? 'right' : 'left';
4262 this.addClass('x-grouptabs-panel');
4264 if (this.tabStyle && this.tabStyle != '') {
4265 this.addClass('x-grouptabs-panel-' + this.tabStyle);
4268 if (this.alternateColor) {
4269 this.addClass(this.alternateCls);
4272 this.on('beforeadd', function(gtp, item, index){
4273 this.initGroup(item, index);
4275 this.items.each(function(item){
4276 item.on('tabchange',function(item){
4277 this.fireEvent('tabchange', this, item.activeTab);
4282 initEvents : function() {
4283 this.mon(this.strip, 'mousedown', this.onStripMouseDown, this);
4286 onRender: function(ct, position){
4287 Ext.TabPanel.superclass.onRender.call(this, ct, position);
4289 var pos = this.tabPosition == 'top' ? 'header' : 'footer';
4290 this[pos].addClass('x-tab-panel-'+pos+'-plain');
4293 var st = this[this.stripTarget];
4295 this.stripWrap = st.createChild({cls:'x-tab-strip-wrap ', cn:{
4296 tag:'ul', cls:'x-grouptabs-strip x-grouptabs-tab-strip-'+this.tabPosition}});
4298 var beforeEl = (this.tabPosition=='bottom' ? this.stripWrap : null);
4299 this.strip = new Ext.Element(this.stripWrap.dom.firstChild);
4301 this.header.addClass('x-grouptabs-panel-header');
4302 this.bwrap.addClass('x-grouptabs-bwrap');
4303 this.body.addClass('x-tab-panel-body-'+this.tabPosition + ' x-grouptabs-panel-body');
4305 if (!this.groupTpl) {
4306 var tt = new Ext.Template(
4307 '<li class="{cls}" id="{id}">',
4308 '<a class="x-grouptabs-expand" onclick="return false;"></a>',
4309 '<a class="x-grouptabs-text {iconCls}" href="#" onclick="return false;">',
4310 '<span>{text}</span></a>',
4313 tt.disableFormats = true;
4315 Ext.ux.GroupTabPanel.prototype.groupTpl = tt;
4317 this.items.each(this.initGroup, this);
4320 afterRender: function(){
4321 Ext.ux.GroupTabPanel.superclass.afterRender.call(this);
4323 this.tabJoint = Ext.fly(this.body.dom.parentNode).createChild({
4327 this.addClass('x-tab-panel-' + this.tabPosition);
4328 this.header.setWidth(this.tabWidth);
4330 if (this.activeGroup !== undefined) {
4331 var group = (typeof this.activeGroup == 'object') ? this.activeGroup : this.items.get(this.activeGroup);
4332 delete this.activeGroup;
4333 this.setActiveGroup(group);
4334 group.setActiveTab(group.getMainItem());
4338 getGroupEl : Ext.TabPanel.prototype.getTabEl,
4341 findTargets: function(e){
4343 itemEl = e.getTarget('li', this.strip);
4345 item = this.findById(itemEl.id.split(this.idDelimiter)[1]);
4346 if (item.disabled) {
4355 expand: e.getTarget('.x-grouptabs-expand', this.strip),
4356 isGroup: !e.getTarget('ul.x-grouptabs-sub', this.strip),
4363 onStripMouseDown: function(e){
4364 if (e.button != 0) {
4368 var t = this.findTargets(e);
4370 this.toggleGroup(t.el);
4374 t.item.setActiveTab(t.item.getMainItem());
4377 t.item.ownerCt.setActiveTab(t.item);
4382 expandGroup: function(groupEl){
4383 if(groupEl.isXType) {
4384 groupEl = this.getGroupEl(groupEl);
4386 Ext.fly(groupEl).addClass('x-grouptabs-expanded');
4387 this.syncTabJoint();
4390 toggleGroup: function(groupEl){
4391 if(groupEl.isXType) {
4392 groupEl = this.getGroupEl(groupEl);
4394 Ext.fly(groupEl).toggleClass('x-grouptabs-expanded');
4395 this.syncTabJoint();
4398 collapseGroup: function(groupEl){
4399 if(groupEl.isXType) {
4400 groupEl = this.getGroupEl(groupEl);
4402 Ext.fly(groupEl).removeClass('x-grouptabs-expanded');
4403 this.syncTabJoint();
4406 syncTabJoint: function(groupEl){
4407 if (!this.tabJoint) {
4411 groupEl = groupEl || this.getGroupEl(this.activeGroup);
4413 this.tabJoint.setHeight(Ext.fly(groupEl).getHeight() - 2);
4415 var y = Ext.isGecko2 ? 0 : 1;
4416 if (this.tabPosition == 'left'){
4417 this.tabJoint.alignTo(groupEl, 'tl-tr', [-2,y]);
4420 this.tabJoint.alignTo(groupEl, 'tr-tl', [1,y]);
4424 this.tabJoint.hide();
4428 getActiveTab : function() {
4429 if(!this.activeGroup) return null;
4430 return this.activeGroup.getTabEl(this.activeGroup.activeTab) || null;
4433 onResize: function(){
4434 Ext.ux.GroupTabPanel.superclass.onResize.apply(this, arguments);
4435 this.syncTabJoint();
4438 createCorner: function(el, pos){
4439 return Ext.fly(el).createChild({
4440 cls: 'x-grouptabs-corner x-grouptabs-corner-' + pos
4444 initGroup: function(group, index){
4445 var before = this.strip.dom.childNodes[index],
4446 p = this.getTemplateArgs(group);
4448 p.cls += ' x-tab-first';
4450 p.cls += ' x-grouptabs-main';
4451 p.text = group.getMainItem().title;
4453 var el = before ? this.groupTpl.insertBefore(before, p) : this.groupTpl.append(this.strip, p),
4454 tl = this.createCorner(el, 'top-' + this.tabPosition),
4455 bl = this.createCorner(el, 'bottom-' + this.tabPosition);
4458 if (group.expanded) {
4459 this.expandGroup(el);
4462 if (Ext.isIE6 || (Ext.isIE && !Ext.isStrict)){
4463 bl.setLeft('-10px');
4464 bl.setBottom('-5px');
4465 tl.setLeft('-10px');
4471 changemainitem: this.onGroupChangeMainItem,
4472 beforetabchange: this.onGroupBeforeTabChange
4476 setActiveGroup : function(group) {
4477 group = this.getComponent(group);
4482 this.activeGroup = group;
4485 if(this.activeGroup != group && this.fireEvent('beforegroupchange', this, group, this.activeGroup) !== false){
4486 if(this.activeGroup){
4487 this.activeGroup.activeTab = null;
4488 var oldEl = this.getGroupEl(this.activeGroup);
4490 Ext.fly(oldEl).removeClass('x-grouptabs-strip-active');
4494 var groupEl = this.getGroupEl(group);
4495 Ext.fly(groupEl).addClass('x-grouptabs-strip-active');
4497 this.activeGroup = group;
4498 this.stack.add(group);
4500 this.layout.setActiveItem(group);
4501 this.syncTabJoint(groupEl);
4503 this.fireEvent('groupchange', this, group);
4509 onGroupBeforeTabChange: function(group, newTab, oldTab){
4510 if(group !== this.activeGroup || newTab !== oldTab) {
4511 this.strip.select('.x-grouptabs-sub > li.x-grouptabs-strip-active', true).removeClass('x-grouptabs-strip-active');
4513 this.expandGroup(this.getGroupEl(group));
4514 if(group !== this.activeGroup) {
4515 return this.setActiveGroup(group);
4519 getFrameHeight: function(){
4520 var h = this.el.getFrameWidth('tb');
4521 h += (this.tbar ? this.tbar.getHeight() : 0) +
4522 (this.bbar ? this.bbar.getHeight() : 0);
4527 adjustBodyWidth: function(w){
4528 return w - this.tabWidth;
4532 Ext.reg('grouptabpanel', Ext.ux.GroupTabPanel);
4534 * Note that this control will most likely remain as an example, and not as a core Ext form
4535 * control. However, the API will be changing in a future release and so should not yet be
4536 * treated as a final, stable API at this time.
4540 * @class Ext.ux.form.ItemSelector
4541 * @extends Ext.form.Field
4542 * A control that allows selection of between two Ext.ux.form.MultiSelect controls.
4545 * 2008-06-19 bpm Original code contributed by Toby Stuart (with contributions from Robert Williams)
4548 * Create a new ItemSelector
4549 * @param {Object} config Configuration options
4550 * @xtype itemselector
4552 Ext.ux.form.ItemSelector = Ext.extend(Ext.form.Field, {
4556 iconDown:"down2.gif",
4557 iconLeft:"left2.gif",
4558 iconRight:"right2.gif",
4560 iconBottom:"bottom2.gif",
4570 defaultAutoCreate:{tag: "div"},
4571 <div id="cfg-Ext.ux.form.ItemSelector-multiselects"></div>/**
4572 * @cfg {Array} multiselects An array of {@link Ext.ux.form.MultiSelect} config objects, with at least all required parameters (e.g., store)
4576 initComponent: function(){
4577 Ext.ux.form.ItemSelector.superclass.initComponent.call(this);
4579 'rowdblclick' : true,
4584 onRender: function(ct, position){
4585 Ext.ux.form.ItemSelector.superclass.onRender.call(this, ct, position);
4587 // Internal default configuration for both multiselects
4589 legend: 'Available',
4602 this.fromMultiselect = new Ext.ux.form.MultiSelect(Ext.applyIf(this.multiselects[0], msConfig[0]));
4603 this.fromMultiselect.on('dblclick', this.onRowDblClick, this);
4605 this.toMultiselect = new Ext.ux.form.MultiSelect(Ext.applyIf(this.multiselects[1], msConfig[1]));
4606 this.toMultiselect.on('dblclick', this.onRowDblClick, this);
4608 var p = new Ext.Panel({
4609 bodyStyle:this.bodyStyle,
4612 layoutConfig:{columns:3}
4615 p.add(this.fromMultiselect);
4616 var icons = new Ext.Panel({header:false});
4618 p.add(this.toMultiselect);
4620 icons.el.down('.'+icons.bwrapCls).remove();
4623 if (this.imagePath!="" && this.imagePath.charAt(this.imagePath.length-1)!="/")
4624 this.imagePath+="/";
4625 this.iconUp = this.imagePath + (this.iconUp || 'up2.gif');
4626 this.iconDown = this.imagePath + (this.iconDown || 'down2.gif');
4627 this.iconLeft = this.imagePath + (this.iconLeft || 'left2.gif');
4628 this.iconRight = this.imagePath + (this.iconRight || 'right2.gif');
4629 this.iconTop = this.imagePath + (this.iconTop || 'top2.gif');
4630 this.iconBottom = this.imagePath + (this.iconBottom || 'bottom2.gif');
4631 var el=icons.getEl();
4632 this.toTopIcon = el.createChild({tag:'img', src:this.iconTop, style:{cursor:'pointer', margin:'2px'}});
4633 el.createChild({tag: 'br'});
4634 this.upIcon = el.createChild({tag:'img', src:this.iconUp, style:{cursor:'pointer', margin:'2px'}});
4635 el.createChild({tag: 'br'});
4636 this.addIcon = el.createChild({tag:'img', src:this.iconRight, style:{cursor:'pointer', margin:'2px'}});
4637 el.createChild({tag: 'br'});
4638 this.removeIcon = el.createChild({tag:'img', src:this.iconLeft, style:{cursor:'pointer', margin:'2px'}});
4639 el.createChild({tag: 'br'});
4640 this.downIcon = el.createChild({tag:'img', src:this.iconDown, style:{cursor:'pointer', margin:'2px'}});
4641 el.createChild({tag: 'br'});
4642 this.toBottomIcon = el.createChild({tag:'img', src:this.iconBottom, style:{cursor:'pointer', margin:'2px'}});
4643 this.toTopIcon.on('click', this.toTop, this);
4644 this.upIcon.on('click', this.up, this);
4645 this.downIcon.on('click', this.down, this);
4646 this.toBottomIcon.on('click', this.toBottom, this);
4647 this.addIcon.on('click', this.fromTo, this);
4648 this.removeIcon.on('click', this.toFrom, this);
4649 if (!this.drawUpIcon || this.hideNavIcons) { this.upIcon.dom.style.display='none'; }
4650 if (!this.drawDownIcon || this.hideNavIcons) { this.downIcon.dom.style.display='none'; }
4651 if (!this.drawLeftIcon || this.hideNavIcons) { this.addIcon.dom.style.display='none'; }
4652 if (!this.drawRightIcon || this.hideNavIcons) { this.removeIcon.dom.style.display='none'; }
4653 if (!this.drawTopIcon || this.hideNavIcons) { this.toTopIcon.dom.style.display='none'; }
4654 if (!this.drawBotIcon || this.hideNavIcons) { this.toBottomIcon.dom.style.display='none'; }
4656 var tb = p.body.first();
4657 this.el.setWidth(p.body.first().getWidth());
4658 p.body.removeClass();
4660 this.hiddenName = this.name;
4661 var hiddenTag = {tag: "input", type: "hidden", value: "", name: this.name};
4662 this.hiddenField = this.el.createChild(hiddenTag);
4665 doLayout: function(){
4667 this.fromMultiselect.fs.doLayout();
4668 this.toMultiselect.fs.doLayout();
4672 afterRender: function(){
4673 Ext.ux.form.ItemSelector.superclass.afterRender.call(this);
4675 this.toStore = this.toMultiselect.store;
4676 this.toStore.on('add', this.valueChanged, this);
4677 this.toStore.on('remove', this.valueChanged, this);
4678 this.toStore.on('load', this.valueChanged, this);
4679 this.valueChanged(this.toStore);
4682 toTop : function() {
4683 var selectionsArray = this.toMultiselect.view.getSelectedIndexes();
4685 if (selectionsArray.length > 0) {
4686 selectionsArray.sort();
4687 for (var i=0; i<selectionsArray.length; i++) {
4688 record = this.toMultiselect.view.store.getAt(selectionsArray[i]);
4689 records.push(record);
4691 selectionsArray = [];
4692 for (var i=records.length-1; i>-1; i--) {
4693 record = records[i];
4694 this.toMultiselect.view.store.remove(record);
4695 this.toMultiselect.view.store.insert(0, record);
4696 selectionsArray.push(((records.length - 1) - i));
4699 this.toMultiselect.view.refresh();
4700 this.toMultiselect.view.select(selectionsArray);
4703 toBottom : function() {
4704 var selectionsArray = this.toMultiselect.view.getSelectedIndexes();
4706 if (selectionsArray.length > 0) {
4707 selectionsArray.sort();
4708 for (var i=0; i<selectionsArray.length; i++) {
4709 record = this.toMultiselect.view.store.getAt(selectionsArray[i]);
4710 records.push(record);
4712 selectionsArray = [];
4713 for (var i=0; i<records.length; i++) {
4714 record = records[i];
4715 this.toMultiselect.view.store.remove(record);
4716 this.toMultiselect.view.store.add(record);
4717 selectionsArray.push((this.toMultiselect.view.store.getCount()) - (records.length - i));
4720 this.toMultiselect.view.refresh();
4721 this.toMultiselect.view.select(selectionsArray);
4726 var selectionsArray = this.toMultiselect.view.getSelectedIndexes();
4727 selectionsArray.sort();
4728 var newSelectionsArray = [];
4729 if (selectionsArray.length > 0) {
4730 for (var i=0; i<selectionsArray.length; i++) {
4731 record = this.toMultiselect.view.store.getAt(selectionsArray[i]);
4732 if ((selectionsArray[i] - 1) >= 0) {
4733 this.toMultiselect.view.store.remove(record);
4734 this.toMultiselect.view.store.insert(selectionsArray[i] - 1, record);
4735 newSelectionsArray.push(selectionsArray[i] - 1);
4738 this.toMultiselect.view.refresh();
4739 this.toMultiselect.view.select(newSelectionsArray);
4745 var selectionsArray = this.toMultiselect.view.getSelectedIndexes();
4746 selectionsArray.sort();
4747 selectionsArray.reverse();
4748 var newSelectionsArray = [];
4749 if (selectionsArray.length > 0) {
4750 for (var i=0; i<selectionsArray.length; i++) {
4751 record = this.toMultiselect.view.store.getAt(selectionsArray[i]);
4752 if ((selectionsArray[i] + 1) < this.toMultiselect.view.store.getCount()) {
4753 this.toMultiselect.view.store.remove(record);
4754 this.toMultiselect.view.store.insert(selectionsArray[i] + 1, record);
4755 newSelectionsArray.push(selectionsArray[i] + 1);
4758 this.toMultiselect.view.refresh();
4759 this.toMultiselect.view.select(newSelectionsArray);
4763 fromTo : function() {
4764 var selectionsArray = this.fromMultiselect.view.getSelectedIndexes();
4766 if (selectionsArray.length > 0) {
4767 for (var i=0; i<selectionsArray.length; i++) {
4768 record = this.fromMultiselect.view.store.getAt(selectionsArray[i]);
4769 records.push(record);
4771 if(!this.allowDup)selectionsArray = [];
4772 for (var i=0; i<records.length; i++) {
4773 record = records[i];
4775 var x=new Ext.data.Record();
4778 this.toMultiselect.view.store.add(record);
4780 this.fromMultiselect.view.store.remove(record);
4781 this.toMultiselect.view.store.add(record);
4782 selectionsArray.push((this.toMultiselect.view.store.getCount() - 1));
4786 this.toMultiselect.view.refresh();
4787 this.fromMultiselect.view.refresh();
4788 var si = this.toMultiselect.store.sortInfo;
4790 this.toMultiselect.store.sort(si.field, si.direction);
4792 this.toMultiselect.view.select(selectionsArray);
4795 toFrom : function() {
4796 var selectionsArray = this.toMultiselect.view.getSelectedIndexes();
4798 if (selectionsArray.length > 0) {
4799 for (var i=0; i<selectionsArray.length; i++) {
4800 record = this.toMultiselect.view.store.getAt(selectionsArray[i]);
4801 records.push(record);
4803 selectionsArray = [];
4804 for (var i=0; i<records.length; i++) {
4805 record = records[i];
4806 this.toMultiselect.view.store.remove(record);
4808 this.fromMultiselect.view.store.add(record);
4809 selectionsArray.push((this.fromMultiselect.view.store.getCount() - 1));
4813 this.fromMultiselect.view.refresh();
4814 this.toMultiselect.view.refresh();
4815 var si = this.fromMultiselect.store.sortInfo;
4817 this.fromMultiselect.store.sort(si.field, si.direction);
4819 this.fromMultiselect.view.select(selectionsArray);
4822 valueChanged: function(store) {
4825 for (var i=0; i<store.getCount(); i++) {
4826 record = store.getAt(i);
4827 values.push(record.get(this.toMultiselect.valueField));
4829 this.hiddenField.dom.value = values.join(this.delimiter);
4830 this.fireEvent('change', this, this.getValue(), this.hiddenField.dom.value);
4833 getValue : function() {
4834 return this.hiddenField.dom.value;
4837 onRowDblClick : function(vw, index, node, e) {
4838 if (vw == this.toMultiselect.view){
4840 } else if (vw == this.fromMultiselect.view) {
4843 return this.fireEvent('rowdblclick', vw, index, node, e);
4847 range = this.toMultiselect.store.getRange();
4848 this.toMultiselect.store.removeAll();
4849 this.fromMultiselect.store.add(range);
4850 var si = this.fromMultiselect.store.sortInfo;
4852 this.fromMultiselect.store.sort(si.field, si.direction);
4854 this.valueChanged(this.toMultiselect.store);
4858 Ext.reg('itemselector', Ext.ux.form.ItemSelector);
4861 Ext.ux.ItemSelector = Ext.ux.form.ItemSelector;
4863 * Ext JS Library 3.3.0
4864 * Copyright(c) 2006-2010 Ext JS, Inc.
4865 * licensing@extjs.com
4866 * http://www.extjs.com/license
4868 Ext.ns('Ext.ux.grid');
4870 Ext.ux.grid.LockingGridView = Ext.extend(Ext.grid.GridView, {
4872 unlockText : 'Unlock',
4874 lockedBorderWidth : 1,
4877 * This option ensures that height between the rows is synchronized
4878 * between the locked and unlocked sides. This option only needs to be used
4879 * when the row heights aren't predictable.
4883 initTemplates : function(){
4884 var ts = this.templates || {};
4886 if (!ts.masterTpl) {
4887 ts.masterTpl = new Ext.Template(
4888 '<div class="x-grid3" hidefocus="true">',
4889 '<div class="x-grid3-locked">',
4890 '<div class="x-grid3-header"><div class="x-grid3-header-inner"><div class="x-grid3-header-offset" style="{lstyle}">{lockedHeader}</div></div><div class="x-clear"></div></div>',
4891 '<div class="x-grid3-scroller"><div class="x-grid3-body" style="{lstyle}">{lockedBody}</div><div class="x-grid3-scroll-spacer"></div></div>',
4893 '<div class="x-grid3-viewport x-grid3-unlocked">',
4894 '<div class="x-grid3-header"><div class="x-grid3-header-inner"><div class="x-grid3-header-offset" style="{ostyle}">{header}</div></div><div class="x-clear"></div></div>',
4895 '<div class="x-grid3-scroller"><div class="x-grid3-body" style="{bstyle}">{body}</div><a href="#" class="x-grid3-focus" tabIndex="-1"></a></div>',
4897 '<div class="x-grid3-resize-marker"> </div>',
4898 '<div class="x-grid3-resize-proxy"> </div>',
4903 this.templates = ts;
4905 Ext.ux.grid.LockingGridView.superclass.initTemplates.call(this);
4908 getEditorParent : function(ed){
4912 initElements : function(){
4913 var el = Ext.get(this.grid.getGridEl().dom.firstChild),
4914 lockedWrap = el.child('div.x-grid3-locked'),
4915 lockedHd = lockedWrap.child('div.x-grid3-header'),
4916 lockedScroller = lockedWrap.child('div.x-grid3-scroller'),
4917 mainWrap = el.child('div.x-grid3-viewport'),
4918 mainHd = mainWrap.child('div.x-grid3-header'),
4919 scroller = mainWrap.child('div.x-grid3-scroller');
4921 if (this.grid.hideHeaders) {
4922 lockedHd.setDisplayed(false);
4923 mainHd.setDisplayed(false);
4927 scroller.setStyle('overflow-x', 'hidden');
4934 innerHd : mainHd.dom.firstChild,
4936 mainBody: scroller.child('div.x-grid3-body'),
4937 focusEl : scroller.child('a'),
4938 resizeMarker: el.child('div.x-grid3-resize-marker'),
4939 resizeProxy : el.child('div.x-grid3-resize-proxy'),
4940 lockedWrap: lockedWrap,
4942 lockedScroller: lockedScroller,
4943 lockedBody: lockedScroller.child('div.x-grid3-body'),
4944 lockedInnerHd: lockedHd.child('div.x-grid3-header-inner', true)
4947 this.focusEl.swallowEvent('click', true);
4950 getLockedRows : function(){
4951 return this.hasRows() ? this.lockedBody.dom.childNodes : [];
4954 getLockedRow : function(row){
4955 return this.getLockedRows()[row];
4958 getCell : function(row, col){
4959 var lockedLen = this.cm.getLockedCount();
4960 if(col < lockedLen){
4961 return this.getLockedRow(row).getElementsByTagName('td')[col];
4963 return Ext.ux.grid.LockingGridView.superclass.getCell.call(this, row, col - lockedLen);
4966 getHeaderCell : function(index){
4967 var lockedLen = this.cm.getLockedCount();
4968 if(index < lockedLen){
4969 return this.lockedHd.dom.getElementsByTagName('td')[index];
4971 return Ext.ux.grid.LockingGridView.superclass.getHeaderCell.call(this, index - lockedLen);
4974 addRowClass : function(row, cls){
4975 var lockedRow = this.getLockedRow(row);
4977 this.fly(lockedRow).addClass(cls);
4979 Ext.ux.grid.LockingGridView.superclass.addRowClass.call(this, row, cls);
4982 removeRowClass : function(row, cls){
4983 var lockedRow = this.getLockedRow(row);
4985 this.fly(lockedRow).removeClass(cls);
4987 Ext.ux.grid.LockingGridView.superclass.removeRowClass.call(this, row, cls);
4990 removeRow : function(row) {
4991 Ext.removeNode(this.getLockedRow(row));
4992 Ext.ux.grid.LockingGridView.superclass.removeRow.call(this, row);
4995 removeRows : function(firstRow, lastRow){
4996 var lockedBody = this.lockedBody.dom,
4997 rowIndex = firstRow;
4998 for(; rowIndex <= lastRow; rowIndex++){
4999 Ext.removeNode(lockedBody.childNodes[firstRow]);
5001 Ext.ux.grid.LockingGridView.superclass.removeRows.call(this, firstRow, lastRow);
5004 syncScroll : function(e){
5005 this.lockedScroller.dom.scrollTop = this.scroller.dom.scrollTop;
5006 Ext.ux.grid.LockingGridView.superclass.syncScroll.call(this, e);
5009 updateSortIcon : function(col, dir){
5010 var sortClasses = this.sortClasses,
5011 lockedHeaders = this.lockedHd.select('td').removeClass(sortClasses),
5012 headers = this.mainHd.select('td').removeClass(sortClasses),
5013 lockedLen = this.cm.getLockedCount(),
5014 cls = sortClasses[dir == 'DESC' ? 1 : 0];
5016 if(col < lockedLen){
5017 lockedHeaders.item(col).addClass(cls);
5019 headers.item(col - lockedLen).addClass(cls);
5023 updateAllColumnWidths : function(){
5024 var tw = this.getTotalWidth(),
5025 clen = this.cm.getColumnCount(),
5026 lw = this.getLockedWidth(),
5027 llen = this.cm.getLockedCount(),
5029 this.updateLockedWidth();
5030 for(i = 0; i < clen; i++){
5031 ws[i] = this.getColumnWidth(i);
5032 var hd = this.getHeaderCell(i);
5033 hd.style.width = ws[i];
5035 var lns = this.getLockedRows(), ns = this.getRows(), row, trow, j;
5036 for(i = 0, len = ns.length; i < len; i++){
5038 row.style.width = lw;
5040 row.firstChild.style.width = lw;
5041 trow = row.firstChild.rows[0];
5042 for (j = 0; j < llen; j++) {
5043 trow.childNodes[j].style.width = ws[j];
5047 row.style.width = tw;
5049 row.firstChild.style.width = tw;
5050 trow = row.firstChild.rows[0];
5051 for (j = llen; j < clen; j++) {
5052 trow.childNodes[j - llen].style.width = ws[j];
5056 this.onAllColumnWidthsUpdated(ws, tw);
5057 this.syncHeaderHeight();
5060 updateColumnWidth : function(col, width){
5061 var w = this.getColumnWidth(col),
5062 llen = this.cm.getLockedCount(),
5064 this.updateLockedWidth();
5066 ns = this.getLockedRows();
5067 rw = this.getLockedWidth();
5070 ns = this.getRows();
5071 rw = this.getTotalWidth();
5074 var hd = this.getHeaderCell(col);
5076 for(var i = 0, len = ns.length; i < len; i++){
5078 row.style.width = rw;
5080 row.firstChild.style.width = rw;
5081 row.firstChild.rows[0].childNodes[c].style.width = w;
5084 this.onColumnWidthUpdated(col, w, this.getTotalWidth());
5085 this.syncHeaderHeight();
5088 updateColumnHidden : function(col, hidden){
5089 var llen = this.cm.getLockedCount(),
5091 display = hidden ? 'none' : '';
5092 this.updateLockedWidth();
5094 ns = this.getLockedRows();
5095 rw = this.getLockedWidth();
5098 ns = this.getRows();
5099 rw = this.getTotalWidth();
5102 var hd = this.getHeaderCell(col);
5103 hd.style.display = display;
5104 for(var i = 0, len = ns.length; i < len; i++){
5106 row.style.width = rw;
5108 row.firstChild.style.width = rw;
5109 row.firstChild.rows[0].childNodes[c].style.display = display;
5112 this.onColumnHiddenUpdated(col, hidden, this.getTotalWidth());
5113 delete this.lastViewWidth;
5117 doRender : function(cs, rs, ds, startRow, colCount, stripe){
5118 var ts = this.templates, ct = ts.cell, rt = ts.row, last = colCount-1,
5119 tstyle = 'width:'+this.getTotalWidth()+';',
5120 lstyle = 'width:'+this.getLockedWidth()+';',
5121 buf = [], lbuf = [], cb, lcb, c, p = {}, rp = {}, r;
5122 for(var j = 0, len = rs.length; j < len; j++){
5123 r = rs[j]; cb = []; lcb = [];
5124 var rowIndex = (j+startRow);
5125 for(var i = 0; i < colCount; i++){
5128 p.css = (i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '')) +
5129 (this.cm.config[i].cellCls ? ' ' + this.cm.config[i].cellCls : '');
5130 p.attr = p.cellAttr = '';
5131 p.value = c.renderer(r.data[c.name], p, r, rowIndex, i, ds);
5133 if(Ext.isEmpty(p.value)){
5136 if(this.markDirty && r.dirty && Ext.isDefined(r.modified[c.name])){
5137 p.css += ' x-grid3-dirty-cell';
5140 lcb[lcb.length] = ct.apply(p);
5142 cb[cb.length] = ct.apply(p);
5146 if(stripe && ((rowIndex+1) % 2 === 0)){
5147 alt[0] = 'x-grid3-row-alt';
5150 alt[1] = ' x-grid3-dirty-row';
5153 if(this.getRowClass){
5154 alt[2] = this.getRowClass(r, rowIndex, rp, ds);
5156 rp.alt = alt.join(' ');
5157 rp.cells = cb.join('');
5159 buf[buf.length] = rt.apply(rp);
5160 rp.cells = lcb.join('');
5162 lbuf[lbuf.length] = rt.apply(rp);
5164 return [buf.join(''), lbuf.join('')];
5166 processRows : function(startRow, skipStripe){
5167 if(!this.ds || this.ds.getCount() < 1){
5170 var rows = this.getRows(),
5171 lrows = this.getLockedRows(),
5173 skipStripe = skipStripe || !this.grid.stripeRows;
5174 startRow = startRow || 0;
5175 for(var i = 0, len = rows.length; i < len; ++i){
5181 row.className = row.className.replace(this.rowClsRe, ' ');
5182 lrow.className = lrow.className.replace(this.rowClsRe, ' ');
5183 if ((i + 1) % 2 === 0){
5184 row.className += ' x-grid3-row-alt';
5185 lrow.className += ' x-grid3-row-alt';
5188 this.syncRowHeights(row, lrow);
5191 Ext.fly(rows[0]).addClass(this.firstRowCls);
5192 Ext.fly(lrows[0]).addClass(this.firstRowCls);
5194 Ext.fly(rows[rows.length - 1]).addClass(this.lastRowCls);
5195 Ext.fly(lrows[lrows.length - 1]).addClass(this.lastRowCls);
5198 syncRowHeights: function(row1, row2){
5199 if(this.syncHeights){
5200 var el1 = Ext.get(row1),
5201 el2 = Ext.get(row2),
5202 h1 = el1.getHeight(),
5203 h2 = el2.getHeight();
5213 afterRender : function(){
5214 if(!this.ds || !this.cm){
5217 var bd = this.renderRows() || [' ', ' '];
5218 this.mainBody.dom.innerHTML = bd[0];
5219 this.lockedBody.dom.innerHTML = bd[1];
5220 this.processRows(0, true);
5221 if(this.deferEmptyText !== true){
5222 this.applyEmptyText();
5224 this.grid.fireEvent('viewready', this.grid);
5227 renderUI : function(){
5228 var templates = this.templates,
5229 header = this.renderHeaders(),
5230 body = templates.body.apply({rows:' '});
5232 return templates.masterTpl.apply({
5235 ostyle: 'width:' + this.getOffsetWidth() + ';',
5236 bstyle: 'width:' + this.getTotalWidth() + ';',
5238 lockedHeader: header[1],
5239 lstyle: 'width:'+this.getLockedWidth()+';'
5243 afterRenderUI: function(){
5245 this.initElements();
5246 Ext.fly(this.innerHd).on('click', this.handleHdDown, this);
5247 Ext.fly(this.lockedInnerHd).on('click', this.handleHdDown, this);
5250 mouseover: this.handleHdOver,
5251 mouseout: this.handleHdOut,
5252 mousemove: this.handleHdMove
5256 mouseover: this.handleHdOver,
5257 mouseout: this.handleHdOut,
5258 mousemove: this.handleHdMove
5260 this.scroller.on('scroll', this.syncScroll, this);
5261 if(g.enableColumnResize !== false){
5262 this.splitZone = new Ext.grid.GridView.SplitDragZone(g, this.mainHd.dom);
5263 this.splitZone.setOuterHandleElId(Ext.id(this.lockedHd.dom));
5264 this.splitZone.setOuterHandleElId(Ext.id(this.mainHd.dom));
5266 if(g.enableColumnMove){
5267 this.columnDrag = new Ext.grid.GridView.ColumnDragZone(g, this.innerHd);
5268 this.columnDrag.setOuterHandleElId(Ext.id(this.lockedInnerHd));
5269 this.columnDrag.setOuterHandleElId(Ext.id(this.innerHd));
5270 this.columnDrop = new Ext.grid.HeaderDropZone(g, this.mainHd.dom);
5272 if(g.enableHdMenu !== false){
5273 this.hmenu = new Ext.menu.Menu({id: g.id + '-hctx'});
5275 {itemId: 'asc', text: this.sortAscText, cls: 'xg-hmenu-sort-asc'},
5276 {itemId: 'desc', text: this.sortDescText, cls: 'xg-hmenu-sort-desc'}
5278 if(this.grid.enableColLock !== false){
5280 {itemId: 'lock', text: this.lockText, cls: 'xg-hmenu-lock'},
5281 {itemId: 'unlock', text: this.unlockText, cls: 'xg-hmenu-unlock'}
5284 if(g.enableColumnHide !== false){
5285 this.colMenu = new Ext.menu.Menu({id:g.id + '-hcols-menu'});
5288 beforeshow: this.beforeColMenuShow,
5289 itemclick: this.handleHdMenuClick
5291 this.hmenu.add('-', {
5294 text: this.columnsText,
5296 iconCls: 'x-cols-icon'
5299 this.hmenu.on('itemclick', this.handleHdMenuClick, this);
5301 if(g.trackMouseOver){
5304 mouseover: this.onRowOver,
5305 mouseout: this.onRowOut
5307 this.lockedBody.on({
5309 mouseover: this.onRowOver,
5310 mouseout: this.onRowOut
5314 if(g.enableDragDrop || g.enableDrag){
5315 this.dragZone = new Ext.grid.GridDragZone(g, {
5316 ddGroup : g.ddGroup || 'GridDD'
5319 this.updateHeaderSortState();
5322 layout : function(){
5327 var c = g.getGridEl();
5328 var csize = c.getSize(true);
5329 var vw = csize.width;
5330 if(!g.hideHeaders && (vw < 20 || csize.height < 20)){
5333 this.syncHeaderHeight();
5335 this.scroller.dom.style.overflow = 'visible';
5336 this.lockedScroller.dom.style.overflow = 'visible';
5338 this.scroller.dom.style.position = 'static';
5339 this.lockedScroller.dom.style.position = 'static';
5342 this.el.setSize(csize.width, csize.height);
5343 var hdHeight = this.mainHd.getHeight();
5344 var vh = csize.height - (hdHeight);
5346 this.updateLockedWidth();
5348 if(this.lastViewWidth != vw){
5349 this.fitColumns(false, false);
5350 this.lastViewWidth = vw;
5354 this.syncHeaderScroll();
5356 this.onLayout(vw, vh);
5359 getOffsetWidth : function() {
5360 return (this.cm.getTotalWidth() - this.cm.getTotalLockedWidth() + this.getScrollOffset()) + 'px';
5363 renderHeaders : function(){
5365 ts = this.templates,
5369 len = cm.getColumnCount(),
5371 for(var i = 0; i < len; i++){
5372 p.id = cm.getColumnId(i);
5373 p.value = cm.getColumnHeader(i) || '';
5374 p.style = this.getColumnStyle(i, true);
5375 p.tooltip = this.getColumnTooltip(i);
5376 p.css = (i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '')) +
5377 (cm.config[i].headerCls ? ' ' + cm.config[i].headerCls : '');
5378 if(cm.config[i].align == 'right'){
5379 p.istyle = 'padding-right:16px';
5384 lcb[lcb.length] = ct.apply(p);
5386 cb[cb.length] = ct.apply(p);
5389 return [ts.header.apply({cells: cb.join(''), tstyle:'width:'+this.getTotalWidth()+';'}),
5390 ts.header.apply({cells: lcb.join(''), tstyle:'width:'+this.getLockedWidth()+';'})];
5393 updateHeaders : function(){
5394 var hd = this.renderHeaders();
5395 this.innerHd.firstChild.innerHTML = hd[0];
5396 this.innerHd.firstChild.style.width = this.getOffsetWidth();
5397 this.innerHd.firstChild.firstChild.style.width = this.getTotalWidth();
5398 this.lockedInnerHd.firstChild.innerHTML = hd[1];
5399 var lw = this.getLockedWidth();
5400 this.lockedInnerHd.firstChild.style.width = lw;
5401 this.lockedInnerHd.firstChild.firstChild.style.width = lw;
5404 getResolvedXY : function(resolved){
5408 var c = resolved.cell, r = resolved.row;
5409 return c ? Ext.fly(c).getXY() : [this.scroller.getX(), Ext.fly(r).getY()];
5412 syncFocusEl : function(row, col, hscroll){
5413 Ext.ux.grid.LockingGridView.superclass.syncFocusEl.call(this, row, col, col < this.cm.getLockedCount() ? false : hscroll);
5416 ensureVisible : function(row, col, hscroll){
5417 return Ext.ux.grid.LockingGridView.superclass.ensureVisible.call(this, row, col, col < this.cm.getLockedCount() ? false : hscroll);
5420 insertRows : function(dm, firstRow, lastRow, isUpdate){
5421 var last = dm.getCount() - 1;
5422 if(!isUpdate && firstRow === 0 && lastRow >= last){
5426 this.fireEvent('beforerowsinserted', this, firstRow, lastRow);
5428 var html = this.renderRows(firstRow, lastRow),
5429 before = this.getRow(firstRow);
5432 this.removeRowClass(0, this.firstRowCls);
5434 Ext.DomHelper.insertHtml('beforeBegin', before, html[0]);
5435 before = this.getLockedRow(firstRow);
5436 Ext.DomHelper.insertHtml('beforeBegin', before, html[1]);
5438 this.removeRowClass(last - 1, this.lastRowCls);
5439 Ext.DomHelper.insertHtml('beforeEnd', this.mainBody.dom, html[0]);
5440 Ext.DomHelper.insertHtml('beforeEnd', this.lockedBody.dom, html[1]);
5443 this.fireEvent('rowsinserted', this, firstRow, lastRow);
5444 this.processRows(firstRow);
5445 }else if(firstRow === 0 || firstRow >= last){
5446 this.addRowClass(firstRow, firstRow === 0 ? this.firstRowCls : this.lastRowCls);
5449 this.syncFocusEl(firstRow);
5452 getColumnStyle : function(col, isHeader){
5453 var style = !isHeader ? this.cm.config[col].cellStyle || this.cm.config[col].css || '' : this.cm.config[col].headerStyle || '';
5454 style += 'width:'+this.getColumnWidth(col)+';';
5455 if(this.cm.isHidden(col)){
5456 style += 'display:none;';
5458 var align = this.cm.config[col].align;
5460 style += 'text-align:'+align+';';
5465 getLockedWidth : function() {
5466 return this.cm.getTotalLockedWidth() + 'px';
5469 getTotalWidth : function() {
5470 return (this.cm.getTotalWidth() - this.cm.getTotalLockedWidth()) + 'px';
5473 getColumnData : function(){
5474 var cs = [], cm = this.cm, colCount = cm.getColumnCount();
5475 for(var i = 0; i < colCount; i++){
5476 var name = cm.getDataIndex(i);
5478 name : (!Ext.isDefined(name) ? this.ds.fields.get(i).name : name),
5479 renderer : cm.getRenderer(i),
5480 id : cm.getColumnId(i),
5481 style : this.getColumnStyle(i),
5482 locked : cm.isLocked(i)
5488 renderBody : function(){
5489 var markup = this.renderRows() || [' ', ' '];
5490 return [this.templates.body.apply({rows: markup[0]}), this.templates.body.apply({rows: markup[1]})];
5493 refreshRow: function(record){
5494 var store = this.ds,
5495 colCount = this.cm.getColumnCount(),
5496 columns = this.getColumnData(),
5497 last = colCount - 1,
5498 cls = ['x-grid3-row'],
5500 tstyle: String.format("width: {0};", this.getTotalWidth())
5503 tstyle: String.format("width: {0};", this.getLockedWidth())
5506 lockedColBuffer = [],
5507 cellTpl = this.templates.cell,
5516 if (Ext.isNumber(record)) {
5518 record = store.getAt(rowIndex);
5520 rowIndex = store.indexOf(record);
5523 if (!record || rowIndex < 0) {
5527 for (i = 0; i < colCount; i++) {
5528 column = columns[i];
5531 css = 'x-grid3-cell-first';
5533 css = (i == last) ? 'x-grid3-cell-last ' : '';
5538 style: column.style,
5544 meta.value = column.renderer.call(column.scope, record.data[column.name], meta, record, rowIndex, i, store);
5546 if (Ext.isEmpty(meta.value)) {
5550 if (this.markDirty && record.dirty && typeof record.modified[column.name] != 'undefined') {
5551 meta.css += ' x-grid3-dirty-cell';
5554 if (column.locked) {
5555 lockedColBuffer[i] = cellTpl.apply(meta);
5557 colBuffer[i] = cellTpl.apply(meta);
5561 row = this.getRow(rowIndex);
5563 lockedRow = this.getLockedRow(rowIndex);
5564 lockedRow.className = '';
5566 if (this.grid.stripeRows && ((rowIndex + 1) % 2 === 0)) {
5567 cls.push('x-grid3-row-alt');
5570 if (this.getRowClass) {
5571 rowParams.cols = colCount;
5572 cls.push(this.getRowClass(record, rowIndex, rowParams, store));
5576 this.fly(row).addClass(cls).setStyle(rowParams.tstyle);
5577 rowParams.cells = colBuffer.join("");
5578 row.innerHTML = this.templates.rowInner.apply(rowParams);
5581 this.fly(lockedRow).addClass(cls).setStyle(lockedRowParams.tstyle);
5582 lockedRowParams.cells = lockedColBuffer.join("");
5583 lockedRow.innerHTML = this.templates.rowInner.apply(lockedRowParams);
5584 lockedRow.rowIndex = rowIndex;
5585 this.syncRowHeights(row, lockedRow);
5586 this.fireEvent('rowupdated', this, rowIndex, record);
5589 refresh : function(headersToo){
5590 this.fireEvent('beforerefresh', this);
5591 this.grid.stopEditing(true);
5592 var result = this.renderBody();
5593 this.mainBody.update(result[0]).setWidth(this.getTotalWidth());
5594 this.lockedBody.update(result[1]).setWidth(this.getLockedWidth());
5595 if(headersToo === true){
5596 this.updateHeaders();
5597 this.updateHeaderSortState();
5599 this.processRows(0, true);
5601 this.applyEmptyText();
5602 this.fireEvent('refresh', this);
5605 onDenyColumnLock : function(){
5609 initData : function(ds, cm){
5611 this.cm.un('columnlockchange', this.onColumnLock, this);
5613 Ext.ux.grid.LockingGridView.superclass.initData.call(this, ds, cm);
5615 this.cm.on('columnlockchange', this.onColumnLock, this);
5619 onColumnLock : function(){
5623 handleHdMenuClick : function(item){
5624 var index = this.hdCtxIndex,
5626 id = item.getItemId(),
5627 llen = cm.getLockedCount();
5630 if(cm.getColumnCount(true) <= llen + 1){
5631 this.onDenyColumnLock();
5634 cm.setLocked(index, true);
5636 cm.moveColumn(index, llen);
5637 this.grid.fireEvent('columnmove', index, llen);
5641 if(llen - 1 != index){
5642 cm.setLocked(index, false, true);
5643 cm.moveColumn(index, llen - 1);
5644 this.grid.fireEvent('columnmove', index, llen - 1);
5646 cm.setLocked(index, false);
5650 return Ext.ux.grid.LockingGridView.superclass.handleHdMenuClick.call(this, item);
5655 handleHdDown : function(e, t){
5656 Ext.ux.grid.LockingGridView.superclass.handleHdDown.call(this, e, t);
5657 if(this.grid.enableColLock !== false){
5658 if(Ext.fly(t).hasClass('x-grid3-hd-btn')){
5659 var hd = this.findHeaderCell(t),
5660 index = this.getCellIndex(hd),
5661 ms = this.hmenu.items, cm = this.cm;
5662 ms.get('lock').setDisabled(cm.isLocked(index));
5663 ms.get('unlock').setDisabled(!cm.isLocked(index));
5668 syncHeaderHeight: function(){
5669 var hrow = Ext.fly(this.innerHd).child('tr', true),
5670 lhrow = Ext.fly(this.lockedInnerHd).child('tr', true);
5672 hrow.style.height = 'auto';
5673 lhrow.style.height = 'auto';
5674 var hd = hrow.offsetHeight,
5675 lhd = lhrow.offsetHeight,
5676 height = Math.max(lhd, hd) + 'px';
5678 hrow.style.height = height;
5679 lhrow.style.height = height;
5683 updateLockedWidth: function(){
5684 var lw = this.cm.getTotalLockedWidth(),
5685 tw = this.cm.getTotalWidth() - lw,
5686 csize = this.grid.getGridEl().getSize(true),
5687 lp = Ext.isBorderBox ? 0 : this.lockedBorderWidth,
5688 rp = Ext.isBorderBox ? 0 : this.rowBorderWidth,
5689 vw = (csize.width - lw - lp - rp) + 'px',
5690 so = this.getScrollOffset();
5691 if(!this.grid.autoHeight){
5692 var vh = (csize.height - this.mainHd.getHeight()) + 'px';
5693 this.lockedScroller.dom.style.height = vh;
5694 this.scroller.dom.style.height = vh;
5696 this.lockedWrap.dom.style.width = (lw + rp) + 'px';
5697 this.scroller.dom.style.width = vw;
5698 this.mainWrap.dom.style.left = (lw + lp + rp) + 'px';
5700 this.lockedInnerHd.firstChild.style.width = lw + 'px';
5701 this.lockedInnerHd.firstChild.firstChild.style.width = lw + 'px';
5702 this.innerHd.style.width = vw;
5703 this.innerHd.firstChild.style.width = (tw + rp + so) + 'px';
5704 this.innerHd.firstChild.firstChild.style.width = tw + 'px';
5707 this.lockedBody.dom.style.width = (lw + rp) + 'px';
5708 this.mainBody.dom.style.width = (tw + rp) + 'px';
5713 Ext.ux.grid.LockingColumnModel = Ext.extend(Ext.grid.ColumnModel, {
5714 <div id="method-Ext.ux.form.ItemSelector-isLocked"></div>/**
5715 * Returns true if the given column index is currently locked
5716 * @param {Number} colIndex The column index
5717 * @return {Boolean} True if the column is locked
5719 isLocked : function(colIndex){
5720 return this.config[colIndex].locked === true;
5723 <div id="method-Ext.ux.form.ItemSelector-setLocked"></div>/**
5724 * Locks or unlocks a given column
5725 * @param {Number} colIndex The column index
5726 * @param {Boolean} value True to lock, false to unlock
5727 * @param {Boolean} suppressEvent Pass false to cause the columnlockchange event not to fire
5729 setLocked : function(colIndex, value, suppressEvent){
5730 if (this.isLocked(colIndex) == value) {
5733 this.config[colIndex].locked = value;
5734 if (!suppressEvent) {
5735 this.fireEvent('columnlockchange', this, colIndex, value);
5739 <div id="method-Ext.ux.form.ItemSelector-getTotalLockedWidth"></div>/**
5740 * Returns the total width of all locked columns
5741 * @return {Number} The width of all locked columns
5743 getTotalLockedWidth : function(){
5745 for (var i = 0, len = this.config.length; i < len; i++) {
5746 if (this.isLocked(i) && !this.isHidden(i)) {
5747 totalWidth += this.getColumnWidth(i);
5754 <div id="method-Ext.ux.form.ItemSelector-getLockedCount"></div>/**
5755 * Returns the total number of locked columns
5756 * @return {Number} The number of locked columns
5758 getLockedCount : function() {
5759 var len = this.config.length;
5761 for (var i = 0; i < len; i++) {
5762 if (!this.isLocked(i)) {
5767 //if we get to this point all of the columns are locked so we return the total
5771 <div id="method-Ext.ux.form.ItemSelector-moveColumn"></div>/**
5772 * Moves a column from one position to another
5773 * @param {Number} oldIndex The current column index
5774 * @param {Number} newIndex The destination column index
5776 moveColumn : function(oldIndex, newIndex){
5777 var oldLocked = this.isLocked(oldIndex),
5778 newLocked = this.isLocked(newIndex);
5780 if (oldIndex < newIndex && oldLocked && !newLocked) {
5781 this.setLocked(oldIndex, false, true);
5782 } else if (oldIndex > newIndex && !oldLocked && newLocked) {
5783 this.setLocked(oldIndex, true, true);
5786 Ext.ux.grid.LockingColumnModel.superclass.moveColumn.apply(this, arguments);
5788 });Ext.ns('Ext.ux.form');
5791 * @class Ext.ux.form.MultiSelect
5792 * @extends Ext.form.Field
5793 * A control that allows selection and form submission of multiple list items.
5796 * 2008-06-19 bpm Original code contributed by Toby Stuart (with contributions from Robert Williams)
5797 * 2008-06-19 bpm Docs and demo code clean up
5800 * Create a new MultiSelect
5801 * @param {Object} config Configuration options
5802 * @xtype multiselect
5804 Ext.ux.form.MultiSelect = Ext.extend(Ext.form.Field, {
5805 <div id="cfg-Ext.ux.form.MultiSelect-legend"></div>/**
5806 * @cfg {String} legend Wraps the object with a fieldset and specified legend.
5808 <div id="cfg-Ext.ux.form.MultiSelect-view"></div>/**
5809 * @cfg {Ext.ListView} view The {@link Ext.ListView} used to render the multiselect list.
5811 <div id="cfg-Ext.ux.form.MultiSelect-dragGroup"></div>/**
5812 * @cfg {String/Array} dragGroup The ddgroup name(s) for the MultiSelect DragZone (defaults to undefined).
5814 <div id="cfg-Ext.ux.form.MultiSelect-dropGroup"></div>/**
5815 * @cfg {String/Array} dropGroup The ddgroup name(s) for the MultiSelect DropZone (defaults to undefined).
5817 <div id="cfg-Ext.ux.form.MultiSelect-ddReorder"></div>/**
5818 * @cfg {Boolean} ddReorder Whether the items in the MultiSelect list are drag/drop reorderable (defaults to false).
5821 <div id="cfg-Ext.ux.form.MultiSelect-tbar"></div>/**
5822 * @cfg {Object/Array} tbar The top toolbar of the control. This can be a {@link Ext.Toolbar} object, a
5823 * toolbar config, or an array of buttons/button configs to be added to the toolbar.
5825 <div id="cfg-Ext.ux.form.MultiSelect-appendOnly"></div>/**
5826 * @cfg {String} appendOnly True if the list should only allow append drops when drag/drop is enabled
5827 * (use for lists which are sorted, defaults to false).
5830 <div id="cfg-Ext.ux.form.MultiSelect-width"></div>/**
5831 * @cfg {Number} width Width in pixels of the control (defaults to 100).
5834 <div id="cfg-Ext.ux.form.MultiSelect-height"></div>/**
5835 * @cfg {Number} height Height in pixels of the control (defaults to 100).
5838 <div id="cfg-Ext.ux.form.MultiSelect-displayField"></div>/**
5839 * @cfg {String/Number} displayField Name/Index of the desired display field in the dataset (defaults to 0).
5842 <div id="cfg-Ext.ux.form.MultiSelect-valueField"></div>/**
5843 * @cfg {String/Number} valueField Name/Index of the desired value field in the dataset (defaults to 1).
5846 <div id="cfg-Ext.ux.form.MultiSelect-allowBlank"></div>/**
5847 * @cfg {Boolean} allowBlank False to require at least one item in the list to be selected, true to allow no
5848 * selection (defaults to true).
5851 <div id="cfg-Ext.ux.form.MultiSelect-minSelections"></div>/**
5852 * @cfg {Number} minSelections Minimum number of selections allowed (defaults to 0).
5855 <div id="cfg-Ext.ux.form.MultiSelect-maxSelections"></div>/**
5856 * @cfg {Number} maxSelections Maximum number of selections allowed (defaults to Number.MAX_VALUE).
5858 maxSelections:Number.MAX_VALUE,
5859 <div id="cfg-Ext.ux.form.MultiSelect-blankText"></div>/**
5860 * @cfg {String} blankText Default text displayed when the control contains no items (defaults to the same value as
5861 * {@link Ext.form.TextField#blankText}.
5863 blankText:Ext.form.TextField.prototype.blankText,
5864 <div id="cfg-Ext.ux.form.MultiSelect-minSelectionsText"></div>/**
5865 * @cfg {String} minSelectionsText Validation message displayed when {@link #minSelections} is not met (defaults to 'Minimum {0}
5866 * item(s) required'). The {0} token will be replaced by the value of {@link #minSelections}.
5868 minSelectionsText:'Minimum {0} item(s) required',
5869 <div id="cfg-Ext.ux.form.MultiSelect-maxSelectionsText"></div>/**
5870 * @cfg {String} maxSelectionsText Validation message displayed when {@link #maxSelections} is not met (defaults to 'Maximum {0}
5871 * item(s) allowed'). The {0} token will be replaced by the value of {@link #maxSelections}.
5873 maxSelectionsText:'Maximum {0} item(s) allowed',
5874 <div id="cfg-Ext.ux.form.MultiSelect-delimiter"></div>/**
5875 * @cfg {String} delimiter The string used to delimit between items when set or returned as a string of values
5876 * (defaults to ',').
5879 <div id="cfg-Ext.ux.form.MultiSelect-store"></div>/**
5880 * @cfg {Ext.data.Store/Array} store The data source to which this MultiSelect is bound (defaults to <tt>undefined</tt>).
5881 * Acceptable values for this property are:
5882 * <div class="mdetail-params"><ul>
5883 * <li><b>any {@link Ext.data.Store Store} subclass</b></li>
5884 * <li><b>an Array</b> : Arrays will be converted to a {@link Ext.data.ArrayStore} internally.
5885 * <div class="mdetail-params"><ul>
5886 * <li><b>1-dimensional array</b> : (e.g., <tt>['Foo','Bar']</tt>)<div class="sub-desc">
5887 * A 1-dimensional array will automatically be expanded (each array item will be the combo
5888 * {@link #valueField value} and {@link #displayField text})</div></li>
5889 * <li><b>2-dimensional array</b> : (e.g., <tt>[['f','Foo'],['b','Bar']]</tt>)<div class="sub-desc">
5890 * For a multi-dimensional array, the value in index 0 of each item will be assumed to be the combo
5891 * {@link #valueField value}, while the value at index 1 is assumed to be the combo {@link #displayField text}.
5892 * </div></li></ul></div></li></ul></div>
5896 defaultAutoCreate : {tag: "div"},
5899 initComponent: function(){
5900 Ext.ux.form.MultiSelect.superclass.initComponent.call(this);
5902 if(Ext.isArray(this.store)){
5903 if (Ext.isArray(this.store[0])){
5904 this.store = new Ext.data.ArrayStore({
5905 fields: ['value','text'],
5908 this.valueField = 'value';
5910 this.store = new Ext.data.ArrayStore({
5915 this.valueField = 'text';
5917 this.displayField = 'text';
5919 this.store = Ext.StoreMgr.lookup(this.store);
5931 onRender: function(ct, position){
5932 Ext.ux.form.MultiSelect.superclass.onRender.call(this, ct, position);
5934 var fs = this.fs = new Ext.form.FieldSet({
5937 height: this.height,
5939 style: "padding:0;",
5942 fs.body.addClass('ux-mselect');
5944 this.view = new Ext.ListView({
5947 columns: [{ header: 'Value', width: 1, dataIndex: this.displayField }],
5953 this.view.on('click', this.onViewClick, this);
5954 this.view.on('beforeclick', this.onViewBeforeClick, this);
5955 this.view.on('dblclick', this.onViewDblClick, this);
5957 this.hiddenName = this.name || Ext.id();
5958 var hiddenTag = { tag: "input", type: "hidden", value: "", name: this.hiddenName };
5959 this.hiddenField = this.el.createChild(hiddenTag);
5960 this.hiddenField.dom.disabled = this.hiddenName != this.name;
5965 afterRender: function(){
5966 Ext.ux.form.MultiSelect.superclass.afterRender.call(this);
5968 if (this.ddReorder && !this.dragGroup && !this.dropGroup){
5969 this.dragGroup = this.dropGroup = 'MultiselectDD-' + Ext.id();
5972 if (this.draggable || this.dragGroup){
5973 this.dragZone = new Ext.ux.form.MultiSelect.DragZone(this, {
5974 ddGroup: this.dragGroup
5977 if (this.droppable || this.dropGroup){
5978 this.dropZone = new Ext.ux.form.MultiSelect.DropZone(this, {
5979 ddGroup: this.dropGroup
5985 onViewClick: function(vw, index, node, e) {
5986 this.fireEvent('change', this, this.getValue(), this.hiddenField.dom.value);
5987 this.hiddenField.dom.value = this.getValue();
5988 this.fireEvent('click', this, e);
5993 onViewBeforeClick: function(vw, index, node, e) {
5994 if (this.disabled || this.readOnly) {
6000 onViewDblClick : function(vw, index, node, e) {
6001 return this.fireEvent('dblclick', vw, index, node, e);
6004 <div id="method-Ext.ux.form.MultiSelect-getValue"></div>/**
6005 * Returns an array of data values for the selected items in the list. The values will be separated
6006 * by {@link #delimiter}.
6007 * @return {Array} value An array of string data values
6009 getValue: function(valueField){
6010 var returnArray = [];
6011 var selectionsArray = this.view.getSelectedIndexes();
6012 if (selectionsArray.length == 0) {return '';}
6013 for (var i=0; i<selectionsArray.length; i++) {
6014 returnArray.push(this.store.getAt(selectionsArray[i]).get((valueField != null) ? valueField : this.valueField));
6016 return returnArray.join(this.delimiter);
6019 <div id="method-Ext.ux.form.MultiSelect-setValue"></div>/**
6020 * Sets a delimited string (using {@link #delimiter}) or array of data values into the list.
6021 * @param {String/Array} values The values to set
6023 setValue: function(values) {
6025 var selections = [];
6026 this.view.clearSelections();
6027 this.hiddenField.dom.value = '';
6029 if (!values || (values == '')) { return; }
6031 if (!Ext.isArray(values)) { values = values.split(this.delimiter); }
6032 for (var i=0; i<values.length; i++) {
6033 index = this.view.store.indexOf(this.view.store.query(this.valueField,
6034 new RegExp('^' + values[i] + '$', "i")).itemAt(0));
6035 selections.push(index);
6037 this.view.select(selections);
6038 this.hiddenField.dom.value = this.getValue();
6043 reset : function() {
6048 getRawValue: function(valueField) {
6049 var tmp = this.getValue(valueField);
6051 tmp = tmp.split(this.delimiter);
6060 setRawValue: function(values){
6065 validateValue : function(value){
6066 if (value.length < 1) { // if it has no value
6067 if (this.allowBlank) {
6068 this.clearInvalid();
6071 this.markInvalid(this.blankText);
6075 if (value.length < this.minSelections) {
6076 this.markInvalid(String.format(this.minSelectionsText, this.minSelections));
6079 if (value.length > this.maxSelections) {
6080 this.markInvalid(String.format(this.maxSelectionsText, this.maxSelections));
6087 disable: function(){
6088 this.disabled = true;
6089 this.hiddenField.dom.disabled = true;
6095 this.disabled = false;
6096 this.hiddenField.dom.disabled = false;
6101 destroy: function(){
6102 Ext.destroy(this.fs, this.dragZone, this.dropZone);
6103 Ext.ux.form.MultiSelect.superclass.destroy.call(this);
6108 Ext.reg('multiselect', Ext.ux.form.MultiSelect);
6111 Ext.ux.Multiselect = Ext.ux.form.MultiSelect;
6114 Ext.ux.form.MultiSelect.DragZone = function(ms, config){
6116 this.view = ms.view;
6117 var ddGroup = config.ddGroup || 'MultiselectDD';
6119 if (Ext.isArray(ddGroup)){
6120 dd = ddGroup.shift();
6125 Ext.ux.form.MultiSelect.DragZone.superclass.constructor.call(this, this.ms.fs.body, { containerScroll: true, ddGroup: dd });
6126 this.setDraggable(ddGroup);
6129 Ext.extend(Ext.ux.form.MultiSelect.DragZone, Ext.dd.DragZone, {
6130 onInitDrag : function(x, y){
6131 var el = Ext.get(this.dragData.ddel.cloneNode(true));
6132 this.proxy.update(el.dom);
6133 el.setWidth(el.child('em').getWidth());
6134 this.onStartDrag(x, y);
6139 collectSelection: function(data) {
6140 data.repairXY = Ext.fly(this.view.getSelectedNodes()[0]).getXY();
6142 this.view.store.each(function(rec){
6143 if (this.view.isSelected(i)) {
6144 var n = this.view.getNode(i);
6145 var dragNode = n.cloneNode(true);
6146 dragNode.id = Ext.id();
6147 data.ddel.appendChild(dragNode);
6148 data.records.push(this.view.store.getAt(i));
6149 data.viewNodes.push(n);
6156 onEndDrag: function(data, e) {
6157 var d = Ext.get(this.dragData.ddel);
6158 if (d && d.hasClass("multi-proxy")) {
6164 getDragData: function(e){
6165 var target = this.view.findItemFromChild(e.getTarget());
6167 if (!this.view.isSelected(target) && !e.ctrlKey && !e.shiftKey) {
6168 this.view.select(target);
6169 this.ms.setValue(this.ms.getValue());
6171 if (this.view.getSelectionCount() == 0 || e.ctrlKey || e.shiftKey) return false;
6173 sourceView: this.view,
6177 if (this.view.getSelectionCount() == 1) {
6178 var i = this.view.getSelectedIndexes()[0];
6179 var n = this.view.getNode(i);
6180 dragData.viewNodes.push(dragData.ddel = n);
6181 dragData.records.push(this.view.store.getAt(i));
6182 dragData.repairXY = Ext.fly(n).getXY();
6184 dragData.ddel = document.createElement('div');
6185 dragData.ddel.className = 'multi-proxy';
6186 this.collectSelection(dragData);
6193 // override the default repairXY.
6194 getRepairXY : function(e){
6195 return this.dragData.repairXY;
6199 setDraggable: function(ddGroup){
6200 if (!ddGroup) return;
6201 if (Ext.isArray(ddGroup)) {
6202 Ext.each(ddGroup, this.setDraggable, this);
6205 this.addToGroup(ddGroup);
6209 Ext.ux.form.MultiSelect.DropZone = function(ms, config){
6211 this.view = ms.view;
6212 var ddGroup = config.ddGroup || 'MultiselectDD';
6214 if (Ext.isArray(ddGroup)){
6215 dd = ddGroup.shift();
6220 Ext.ux.form.MultiSelect.DropZone.superclass.constructor.call(this, this.ms.fs.body, { containerScroll: true, ddGroup: dd });
6221 this.setDroppable(ddGroup);
6224 Ext.extend(Ext.ux.form.MultiSelect.DropZone, Ext.dd.DropZone, {
6225 <div id="method-Ext.ux.form.MultiSelect-getTargetFromEvent"></div>/**
6226 * Part of the Ext.dd.DropZone interface. If no target node is found, the
6227 * whole Element becomes the target, and this causes the drop gesture to append.
6229 getTargetFromEvent : function(e) {
6230 var target = e.getTarget();
6235 getDropPoint : function(e, n, dd){
6236 if (n == this.ms.fs.body.dom) { return "below"; }
6237 var t = Ext.lib.Dom.getY(n), b = t + n.offsetHeight;
6238 var c = t + (b - t) / 2;
6239 var y = Ext.lib.Event.getPageY(e);
6248 isValidDropPoint: function(pt, n, data) {
6249 if (!data.viewNodes || (data.viewNodes.length != 1)) {
6252 var d = data.viewNodes[0];
6256 if ((pt == "below") && (n.nextSibling == d)) {
6259 if ((pt == "above") && (n.previousSibling == d)) {
6266 onNodeEnter : function(n, dd, e, data){
6271 onNodeOver : function(n, dd, e, data){
6272 var dragElClass = this.dropNotAllowed;
6273 var pt = this.getDropPoint(e, n, dd);
6274 if (this.isValidDropPoint(pt, n, data)) {
6275 if (this.ms.appendOnly) {
6276 return "x-tree-drop-ok-below";
6279 // set the insert point style on the target node
6283 dragElClass = n.previousSibling ? "x-tree-drop-ok-between" : "x-tree-drop-ok-above";
6284 targetElClass = "x-view-drag-insert-above";
6286 dragElClass = n.nextSibling ? "x-tree-drop-ok-between" : "x-tree-drop-ok-below";
6287 targetElClass = "x-view-drag-insert-below";
6289 if (this.lastInsertClass != targetElClass){
6290 Ext.fly(n).replaceClass(this.lastInsertClass, targetElClass);
6291 this.lastInsertClass = targetElClass;
6299 onNodeOut : function(n, dd, e, data){
6300 this.removeDropIndicators(n);
6304 onNodeDrop : function(n, dd, e, data){
6305 if (this.ms.fireEvent("drop", this, n, dd, e, data) === false) {
6308 var pt = this.getDropPoint(e, n, dd);
6309 if (n != this.ms.fs.body.dom)
6310 n = this.view.findItemFromChild(n);
6312 if(this.ms.appendOnly) {
6313 insertAt = this.view.store.getCount();
6315 insertAt = n == this.ms.fs.body.dom ? this.view.store.getCount() - 1 : this.view.indexOf(n);
6316 if (pt == "below") {
6323 // Validate if dragging within the same MultiSelect
6324 if (data.sourceView == this.view) {
6325 // If the first element to be inserted below is the target node, remove it
6326 if (pt == "below") {
6327 if (data.viewNodes[0] == n) {
6328 data.viewNodes.shift();
6330 } else { // If the last element to be inserted above is the target node, remove it
6331 if (data.viewNodes[data.viewNodes.length - 1] == n) {
6332 data.viewNodes.pop();
6336 // Nothing to drop...
6337 if (!data.viewNodes.length) {
6341 // If we are moving DOWN, then because a store.remove() takes place first,
6342 // the insertAt must be decremented.
6343 if (insertAt > this.view.store.indexOf(data.records[0])) {
6349 for (var i = 0; i < data.records.length; i++) {
6350 var r = data.records[i];
6351 if (data.sourceView) {
6352 data.sourceView.store.remove(r);
6354 this.view.store.insert(dir == 'down' ? insertAt : insertAt++, r);
6355 var si = this.view.store.sortInfo;
6357 this.view.store.sort(si.field, si.direction);
6364 removeDropIndicators : function(n){
6366 Ext.fly(n).removeClass([
6367 "x-view-drag-insert-above",
6368 "x-view-drag-insert-left",
6369 "x-view-drag-insert-right",
6370 "x-view-drag-insert-below"]);
6371 this.lastInsertClass = "_noclass";
6376 setDroppable: function(ddGroup){
6377 if (!ddGroup) return;
6378 if (Ext.isArray(ddGroup)) {
6379 Ext.each(ddGroup, this.setDroppable, this);
6382 this.addToGroup(ddGroup);
6386 /* Fix for Opera, which does not seem to include the map function on Array's */
6387 if (!Array.prototype.map) {
6388 Array.prototype.map = function(fun){
6389 var len = this.length;
6390 if (typeof fun != 'function') {
6391 throw new TypeError();
6393 var res = new Array(len);
6394 var thisp = arguments[1];
6395 for (var i = 0; i < len; i++) {
6397 res[i] = fun.call(thisp, this[i], i, this);
6404 Ext.ns('Ext.ux.data');
6407 * @class Ext.ux.data.PagingMemoryProxy
6408 * @extends Ext.data.MemoryProxy
6409 * <p>Paging Memory Proxy, allows to use paging grid with in memory dataset</p>
6411 Ext.ux.data.PagingMemoryProxy = Ext.extend(Ext.data.MemoryProxy, {
6412 constructor : function(data){
6413 Ext.ux.data.PagingMemoryProxy.superclass.constructor.call(this);
6416 doRequest : function(action, rs, params, reader, callback, scope, options){
6421 result = reader.readRecords(this.data);
6424 this.fireEvent('loadexception', this, options, null, e);
6425 callback.call(scope, null, options, false);
6430 if (params.filter !== undefined) {
6431 result.records = result.records.filter(function(el){
6432 if (typeof(el) == 'object') {
6433 var att = params.filterCol || 0;
6434 return String(el.data[att]).match(params.filter) ? true : false;
6437 return String(el).match(params.filter) ? true : false;
6440 result.totalRecords = result.records.length;
6444 if (params.sort !== undefined) {
6445 // use integer as params.sort to specify column, since arrays are not named
6446 // params.sort=0; would also match a array without columns
6447 var dir = String(params.dir).toUpperCase() == 'DESC' ? -1 : 1;
6448 var fn = function(v1, v2){
6449 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
6451 result.records.sort(function(a, b){
6453 if (typeof(a) == 'object') {
6454 v = fn(a.data[params.sort], b.data[params.sort]) * dir;
6460 v = (a.index < b.index ? -1 : 1);
6465 // paging (use undefined cause start can also be 0 (thus false))
6466 if (params.start !== undefined && params.limit !== undefined) {
6467 result.records = result.records.slice(params.start, params.start + params.limit);
6469 callback.call(scope, result, options, true);
6474 Ext.data.PagingMemoryProxy = Ext.ux.data.PagingMemoryProxy;
6475 Ext.ux.PanelResizer = Ext.extend(Ext.util.Observable, {
6479 constructor: function(config){
6480 Ext.apply(this, config);
6482 Ext.ux.PanelResizer.superclass.constructor.call(this, config);
6488 if(this.panel.elements.indexOf('footer')==-1){
6489 p.elements += ',footer';
6491 p.on('render', this.onRender, this);
6494 onRender : function(p){
6495 this.handle = p.footer.createChild({cls:'x-panel-resize'});
6497 this.tracker = new Ext.dd.DragTracker({
6498 onStart: this.onDragStart.createDelegate(this),
6499 onDrag: this.onDrag.createDelegate(this),
6500 onEnd: this.onDragEnd.createDelegate(this),
6504 this.tracker.initEl(this.handle);
6505 p.on('beforedestroy', this.tracker.destroy, this.tracker);
6509 onDragStart: function(e){
6510 this.dragging = true;
6511 this.startHeight = this.panel.el.getHeight();
6512 this.fireEvent('dragstart', this, e);
6516 onDrag: function(e){
6517 this.panel.setHeight((this.startHeight-this.tracker.getOffset()[1]).constrain(this.minHeight, this.maxHeight));
6518 this.fireEvent('drag', this, e);
6522 onDragEnd: function(e){
6523 this.dragging = false;
6524 this.fireEvent('dragend', this, e);
6527 Ext.preg('panelresizer', Ext.ux.PanelResizer);Ext.ux.Portal = Ext.extend(Ext.Panel, {
6531 defaultType : 'portalcolumn',
6533 initComponent : function(){
6534 Ext.ux.Portal.superclass.initComponent.call(this);
6537 beforedragover:true,
6544 initEvents : function(){
6545 Ext.ux.Portal.superclass.initEvents.call(this);
6546 this.dd = new Ext.ux.Portal.DropZone(this, this.dropConfig);
6549 beforeDestroy : function() {
6553 Ext.ux.Portal.superclass.beforeDestroy.call(this);
6557 Ext.reg('portal', Ext.ux.Portal);
6559 Ext.ux.Portal.DropZone = Ext.extend(Ext.dd.DropTarget, {
6561 constructor : function(portal, cfg){
6562 this.portal = portal;
6563 Ext.dd.ScrollManager.register(portal.body);
6564 Ext.ux.Portal.DropZone.superclass.constructor.call(this, portal.bwrap.dom, cfg);
6565 portal.body.ddScrollConfig = this.ddScrollConfig;
6575 createEvent : function(dd, e, data, col, c, pos){
6577 portal: this.portal,
6585 status: this.dropAllowed
6589 notifyOver : function(dd, e, data){
6590 var xy = e.getXY(), portal = this.portal, px = dd.proxy;
6592 // case column widths
6594 this.grid = this.getGrid();
6597 // handle case scroll where scrollbars appear during drag
6598 var cw = portal.body.dom.clientWidth;
6601 }else if(this.lastCW != cw){
6604 this.grid = this.getGrid();
6608 var col = 0, xs = this.grid.columnX, cmatch = false;
6609 for(var len = xs.length; col < len; col++){
6610 if(xy[0] < (xs[col].x + xs[col].w)){
6615 // no match, fix last index
6620 // find insert position
6621 var p, match = false, pos = 0,
6622 c = portal.items.itemAt(col),
6623 items = c.items.items, overSelf = false;
6625 for(var len = items.length; pos < len; pos++){
6627 var h = p.el.getHeight();
6631 else if((p.el.getY()+(h/2)) > xy[1]){
6637 pos = (match && p ? pos : c.items.getCount()) + (overSelf ? -1 : 0);
6638 var overEvent = this.createEvent(dd, e, data, col, c, pos);
6640 if(portal.fireEvent('validatedrop', overEvent) !== false &&
6641 portal.fireEvent('beforedragover', overEvent) !== false){
6643 // make sure proxy width is fluid
6644 px.getProxy().setWidth('auto');
6647 px.moveProxy(p.el.dom.parentNode, match ? p.el.dom : null);
6649 px.moveProxy(c.el.dom, null);
6652 this.lastPos = {c: c, col: col, p: overSelf || (match && p) ? pos : false};
6653 this.scrollPos = portal.body.getScroll();
6655 portal.fireEvent('dragover', overEvent);
6657 return overEvent.status;
6659 return overEvent.status;
6664 notifyOut : function(){
6668 notifyDrop : function(dd, e, data){
6673 var c = this.lastPos.c,
6674 col = this.lastPos.col,
6675 pos = this.lastPos.p,
6677 dropEvent = this.createEvent(dd, e, data, col, c,
6678 pos !== false ? pos : c.items.getCount());
6680 if(this.portal.fireEvent('validatedrop', dropEvent) !== false &&
6681 this.portal.fireEvent('beforedrop', dropEvent) !== false){
6683 dd.proxy.getProxy().remove();
6684 panel.el.dom.parentNode.removeChild(dd.panel.el.dom);
6687 c.insert(pos, panel);
6694 this.portal.fireEvent('drop', dropEvent);
6696 // scroll position is lost on drop, fix it
6697 var st = this.scrollPos.top;
6699 var d = this.portal.body.dom;
6700 setTimeout(function(){
6706 delete this.lastPos;
6709 // internal cache of body and column coords
6710 getGrid : function(){
6711 var box = this.portal.bwrap.getBox();
6713 this.portal.items.each(function(c){
6714 box.columnX.push({x: c.el.getX(), w: c.el.getWidth()});
6719 // unregister the dropzone from ScrollManager
6721 Ext.dd.ScrollManager.unregister(this.portal.body);
6722 Ext.ux.Portal.DropZone.superclass.unreg.call(this);
6725 Ext.ux.PortalColumn = Ext.extend(Ext.Container, {
6727 //autoEl : 'div',//already defined by Ext.Component
6728 defaultType : 'portlet',
6729 cls : 'x-portal-column'
6732 Ext.reg('portalcolumn', Ext.ux.PortalColumn);
6733 Ext.ux.Portlet = Ext.extend(Ext.Panel, {
6741 Ext.reg('portlet', Ext.ux.Portlet);
6742 <div id="cls-Ext.ux.ProgressBarPager"></div>/**
6743 * @class Ext.ux.ProgressBarPager
6745 * Plugin (ptype = 'tabclosemenu') for displaying a progressbar inside of a paging toolbar instead of plain text
6747 * @ptype progressbarpager
6749 * Create a new ItemSelector
6750 * @param {Object} config Configuration options
6751 * @xtype itemselector
6753 Ext.ux.ProgressBarPager = Ext.extend(Object, {
6754 <div id="cfg-Ext.ux.ProgressBarPager-progBarWidth"></div>/**
6755 * @cfg {Integer} progBarWidth
6756 * <p>The default progress bar width. Default is 225.</p>
6759 <div id="cfg-Ext.ux.ProgressBarPager-defaultText"></div>/**
6760 * @cfg {String} defaultText
6761 * <p>The text to display while the store is loading. Default is 'Loading...'</p>
6763 defaultText : 'Loading...',
6764 <div id="cfg-Ext.ux.ProgressBarPager-defaultAnimCfg"></div>/**
6765 * @cfg {Object} defaultAnimCfg
6766 * <p>A {@link Ext.Fx Ext.Fx} configuration object. Default is { duration : 1, easing : 'bounceOut' }.</p>
6770 easing : 'bounceOut'
6772 constructor : function(config) {
6774 Ext.apply(this, config);
6778 init : function (parent) {
6780 if(parent.displayInfo){
6781 this.parent = parent;
6782 var ind = parent.items.indexOf(parent.displayItem);
6783 parent.remove(parent.displayItem, true);
6784 this.progressBar = new Ext.ProgressBar({
6785 text : this.defaultText,
6786 width : this.progBarWidth,
6787 animate : this.defaultAnimCfg
6790 parent.displayItem = this.progressBar;
6792 parent.add(parent.displayItem);
6794 Ext.apply(parent, this.parentOverrides);
6796 this.progressBar.on('render', function(pb) {
6797 pb.mon(pb.getEl().applyStyles('cursor:pointer'), 'click', this.handleProgressBarClick, this);
6798 }, this, {single: true});
6804 // This method handles the click for the progress bar
6805 handleProgressBarClick : function(e){
6806 var parent = this.parent,
6807 displayItem = parent.displayItem,
6808 box = this.progressBar.getBox(),
6810 position = xy[0]-box.x,
6811 pages = Math.ceil(parent.store.getTotalCount()/parent.pageSize),
6812 newpage = Math.ceil(position/(displayItem.width/pages));
6814 parent.changePage(newpage);
6817 // private, overriddes
6820 // This method updates the information via the progress bar.
6821 updateInfo : function(){
6822 if(this.displayItem){
6823 var count = this.store.getCount(),
6824 pgData = this.getPageData(),
6825 pageNum = this.readPage(pgData),
6830 this.cursor+1, this.cursor+count, this.store.getTotalCount()
6833 pageNum = pgData.activePage; ;
6835 var pct = pageNum / pgData.pages;
6837 this.displayItem.updateProgress(pct, msg, this.animate || this.defaultAnimConfig);
6842 Ext.preg('progressbarpager', Ext.ux.ProgressBarPager);
6844 Ext.ns('Ext.ux.grid');
6846 <div id="cls-Ext.ux.grid.RowEditor"></div>/**
6847 * @class Ext.ux.grid.RowEditor
6848 * @extends Ext.Panel
6849 * Plugin (ptype = 'roweditor') that adds the ability to rapidly edit full rows in a grid.
6850 * A validation mode may be enabled which uses AnchorTips to notify the user of all
6851 * validation errors at once.
6855 Ext.ux.grid.RowEditor = Ext.extend(Ext.Panel, {
6859 cls: 'x-small-editor',
6860 buttonAlign: 'center',
6861 baseCls: 'x-row-editor',
6862 elements: 'header,footer,body',
6865 clicksToEdit: 'auto',
6871 cancelText: 'Cancel',
6872 commitChangesText: 'You need to commit or cancel your changes',
6873 errorText: 'Errors',
6879 initComponent: function(){
6880 Ext.ux.grid.RowEditor.superclass.initComponent.call(this);
6882 <div id="event-Ext.ux.grid.RowEditor-beforeedit"></div>/**
6884 * Fired before the row editor is activated.
6885 * If the listener returns <tt>false</tt> the editor will not be activated.
6886 * @param {Ext.ux.grid.RowEditor} roweditor This object
6887 * @param {Number} rowIndex The rowIndex of the row just edited
6890 <div id="event-Ext.ux.grid.RowEditor-canceledit"></div>/**
6892 * Fired when the editor is cancelled.
6893 * @param {Ext.ux.grid.RowEditor} roweditor This object
6894 * @param {Boolean} forced True if the cancel button is pressed, false is the editor was invalid.
6897 <div id="event-Ext.ux.grid.RowEditor-validateedit"></div>/**
6898 * @event validateedit
6899 * Fired after a row is edited and passes validation.
6900 * If the listener returns <tt>false</tt> changes to the record will not be set.
6901 * @param {Ext.ux.grid.RowEditor} roweditor This object
6902 * @param {Object} changes Object with changes made to the record.
6903 * @param {Ext.data.Record} r The Record that was edited.
6904 * @param {Number} rowIndex The rowIndex of the row just edited
6907 <div id="event-Ext.ux.grid.RowEditor-afteredit"></div>/**
6909 * Fired after a row is edited and passes validation. This event is fired
6910 * after the store's update event is fired with this edit.
6911 * @param {Ext.ux.grid.RowEditor} roweditor This object
6912 * @param {Object} changes Object with changes made to the record.
6913 * @param {Ext.data.Record} r The Record that was edited.
6914 * @param {Number} rowIndex The rowIndex of the row just edited
6920 init: function(grid){
6922 this.ownerCt = grid;
6923 if(this.clicksToEdit === 2){
6924 grid.on('rowdblclick', this.onRowDblClick, this);
6926 grid.on('rowclick', this.onRowClick, this);
6928 grid.on('rowdblclick', this.onRowDblClick, this);
6932 // stopEditing without saving when a record is removed from Store.
6933 grid.getStore().on('remove', function() {
6934 this.stopEditing(false);
6939 keydown: this.onGridKey,
6940 columnresize: this.verifyLayout,
6941 columnmove: this.refreshFields,
6942 reconfigure: this.refreshFields,
6943 beforedestroy : this.beforedestroy,
6944 destroy : this.destroy,
6947 fn: this.positionButtons
6950 grid.getColumnModel().on('hiddenchange', this.verifyLayout, this, {delay:1});
6951 grid.getView().on('refresh', this.stopEditing.createDelegate(this, []));
6954 beforedestroy: function() {
6955 this.stopMonitoring();
6956 this.grid.getStore().un('remove', this.onStoreRemove, this);
6957 this.stopEditing(false);
6958 Ext.destroy(this.btns, this.tooltip);
6961 refreshFields: function(){
6963 this.verifyLayout();
6966 isDirty: function(){
6968 this.items.each(function(f){
6969 if(String(this.values[f.id]) !== String(f.getValue())){
6977 startEditing: function(rowIndex, doFocus){
6978 if(this.editing && this.isDirty()){
6979 this.showTooltip(this.commitChangesText);
6982 if(Ext.isObject(rowIndex)){
6983 rowIndex = this.grid.getStore().indexOf(rowIndex);
6985 if(this.fireEvent('beforeedit', this, rowIndex) !== false){
6986 this.editing = true;
6987 var g = this.grid, view = g.getView(),
6988 row = view.getRow(rowIndex),
6989 record = g.store.getAt(rowIndex);
6991 this.record = record;
6992 this.rowIndex = rowIndex;
6995 this.render(view.getEditorParent());
6997 var w = Ext.fly(row).getWidth();
6999 if(!this.initialized){
7002 var cm = g.getColumnModel(), fields = this.items.items, f, val;
7003 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
7004 val = this.preEditValue(record, cm.getDataIndex(i));
7007 this.values[f.id] = Ext.isEmpty(val) ? '' : val;
7009 this.verifyLayout(true);
7010 if(!this.isVisible()){
7011 this.setPagePosition(Ext.fly(row).getXY());
7013 this.el.setXY(Ext.fly(row).getXY(), {duration:0.15});
7015 if(!this.isVisible()){
7016 this.show().doLayout();
7018 if(doFocus !== false){
7019 this.doFocus.defer(this.focusDelay, this);
7024 stopEditing : function(saveChanges){
7025 this.editing = false;
7026 if(!this.isVisible()){
7029 if(saveChanges === false || !this.isValid()){
7031 this.fireEvent('canceledit', this, saveChanges === false);
7037 cm = this.grid.colModel,
7038 fields = this.items.items;
7039 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
7040 if(!cm.isHidden(i)){
7041 var dindex = cm.getDataIndex(i);
7042 if(!Ext.isEmpty(dindex)){
7043 var oldValue = r.data[dindex],
7044 value = this.postEditValue(fields[i].getValue(), oldValue, r, dindex);
7045 if(String(oldValue) !== String(value)){
7046 changes[dindex] = value;
7052 if(hasChange && this.fireEvent('validateedit', this, changes, r, this.rowIndex) !== false){
7054 Ext.iterate(changes, function(name, value){
7058 this.fireEvent('afteredit', this, changes, r, this.rowIndex);
7063 verifyLayout: function(force){
7064 if(this.el && (this.isVisible() || force === true)){
7065 var row = this.grid.getView().getRow(this.rowIndex);
7066 this.setSize(Ext.fly(row).getWidth(), Ext.isIE ? Ext.fly(row).getHeight() + 9 : undefined);
7067 var cm = this.grid.colModel, fields = this.items.items;
7068 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
7069 if(!cm.isHidden(i)){
7071 if(i === (len - 1)){
7072 adjust += 3; // outer padding
7077 fields[i].setWidth(cm.getColumnWidth(i) - adjust);
7083 this.positionButtons();
7087 slideHide : function(){
7091 initFields: function(){
7092 var cm = this.grid.getColumnModel(), pm = Ext.layout.ContainerLayout.prototype.parseMargins;
7093 this.removeAll(false);
7094 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
7095 var c = cm.getColumnAt(i),
7098 ed = c.displayEditor || new Ext.form.DisplayField();
7101 ed.margins = pm('0 1 2 1');
7102 } else if(i == len - 1){
7103 ed.margins = pm('0 0 2 1');
7106 ed.margins = pm('0 0 2 0');
7109 ed.margins = pm('0 1 2 0');
7112 ed.setWidth(cm.getColumnWidth(i));
7114 if(ed.ownerCt !== this){
7115 ed.on('focus', this.ensureVisible, this);
7116 ed.on('specialkey', this.onKey, this);
7120 this.initialized = true;
7123 onKey: function(f, e){
7124 if(e.getKey() === e.ENTER){
7125 this.stopEditing(true);
7126 e.stopPropagation();
7130 onGridKey: function(e){
7131 if(e.getKey() === e.ENTER && !this.isVisible()){
7132 var r = this.grid.getSelectionModel().getSelected();
7134 var index = this.grid.store.indexOf(r);
7135 this.startEditing(index);
7136 e.stopPropagation();
7141 ensureVisible: function(editor){
7142 if(this.isVisible()){
7143 this.grid.getView().ensureVisible(this.rowIndex, this.grid.colModel.getIndexById(editor.column.id), true);
7147 onRowClick: function(g, rowIndex, e){
7148 if(this.clicksToEdit == 'auto'){
7149 var li = this.lastClickIndex;
7150 this.lastClickIndex = rowIndex;
7151 if(li != rowIndex && !this.isVisible()){
7155 this.startEditing(rowIndex, false);
7156 this.doFocus.defer(this.focusDelay, this, [e.getPoint()]);
7159 onRowDblClick: function(g, rowIndex, e){
7160 this.startEditing(rowIndex, false);
7161 this.doFocus.defer(this.focusDelay, this, [e.getPoint()]);
7164 onRender: function(){
7165 Ext.ux.grid.RowEditor.superclass.onRender.apply(this, arguments);
7166 this.el.swallowEvent(['keydown', 'keyup', 'keypress']);
7167 this.btns = new Ext.Panel({
7172 width: (this.minButtonWidth * 2) + (this.frameWidth * 2) + (this.buttonPad * 4), // width must be specified for IE
7177 text: this.saveText,
7178 width: this.minButtonWidth,
7179 handler: this.stopEditing.createDelegate(this, [true])
7182 text: this.cancelText,
7183 width: this.minButtonWidth,
7184 handler: this.stopEditing.createDelegate(this, [false])
7187 this.btns.render(this.bwrap);
7190 afterRender: function(){
7191 Ext.ux.grid.RowEditor.superclass.afterRender.apply(this, arguments);
7192 this.positionButtons();
7193 if(this.monitorValid){
7194 this.startMonitoring();
7199 if(this.monitorValid){
7200 this.startMonitoring();
7202 Ext.ux.grid.RowEditor.superclass.onShow.apply(this, arguments);
7206 Ext.ux.grid.RowEditor.superclass.onHide.apply(this, arguments);
7207 this.stopMonitoring();
7208 this.grid.getView().focusRow(this.rowIndex);
7211 positionButtons: function(){
7214 h = this.el.dom.clientHeight,
7216 scroll = view.scroller.dom.scrollLeft,
7217 bw = this.btns.getWidth(),
7218 width = Math.min(g.getWidth(), g.getColumnModel().getTotalWidth());
7220 this.btns.el.shift({left: (width/2)-(bw/2)+scroll, top: h - 2, stopFx: true, duration:0.2});
7225 preEditValue : function(r, field){
7226 var value = r.data[field];
7227 return this.autoEncode && typeof value === 'string' ? Ext.util.Format.htmlDecode(value) : value;
7231 postEditValue : function(value, originalValue, r, field){
7232 return this.autoEncode && typeof value == 'string' ? Ext.util.Format.htmlEncode(value) : value;
7235 doFocus: function(pt){
7236 if(this.isVisible()){
7238 cm = this.grid.getColumnModel(),
7241 index = this.getTargetColumnIndex(pt);
7243 for(var i = index||0, len = cm.getColumnCount(); i < len; i++){
7244 c = cm.getColumnAt(i);
7245 if(!c.hidden && c.getEditor()){
7246 c.getEditor().focus();
7253 getTargetColumnIndex: function(pt){
7254 var grid = this.grid,
7257 cms = grid.colModel.config,
7260 for(var len = cms.length, c; c = cms[i]; i++){
7262 if(Ext.fly(v.getHeaderCell(i)).getRegion().right >= x){
7271 startMonitoring : function(){
7272 if(!this.bound && this.monitorValid){
7275 run : this.bindHandler,
7276 interval : this.monitorPoll || 200,
7282 stopMonitoring : function(){
7285 this.tooltip.hide();
7289 isValid: function(){
7291 this.items.each(function(f){
7292 if(!f.isValid(true)){
7301 bindHandler : function(){
7303 return false; // stops binding
7305 var valid = this.isValid();
7306 if(!valid && this.errorSummary){
7307 this.showTooltip(this.getErrorText().join(''));
7309 this.btns.saveBtn.setDisabled(!valid);
7310 this.fireEvent('validation', this, valid);
7313 lastVisibleColumn : function() {
7314 var i = this.items.getCount() - 1,
7316 for(; i >= 0; i--) {
7317 c = this.items.items[i];
7324 showTooltip: function(msg){
7325 var t = this.tooltip;
7327 t = this.tooltip = new Ext.ToolTip({
7331 title: this.errorText,
7334 anchorToTarget: true,
7338 var v = this.grid.getView(),
7339 top = parseInt(this.el.dom.style.top, 10),
7340 scroll = v.scroller.dom.scrollTop,
7341 h = this.el.getHeight();
7343 if(top + h >= scroll){
7344 t.initTarget(this.lastVisibleColumn().getEl());
7352 }else if(t.rendered){
7357 getErrorText: function(){
7358 var data = ['<ul>'];
7359 this.items.each(function(f){
7360 if(!f.isValid(true)){
7361 data.push('<li>', f.getActiveError(), '</li>');
7368 Ext.preg('roweditor', Ext.ux.grid.RowEditor);
7369 Ext.ns('Ext.ux.grid');
7372 * @class Ext.ux.grid.RowExpander
7373 * @extends Ext.util.Observable
7374 * Plugin (ptype = 'rowexpander') that adds the ability to have a Column in a grid which enables
7375 * a second row body which expands/contracts. The expand/contract behavior is configurable to react
7376 * on clicking of the column, double click of the row, and/or hitting enter while a row is selected.
7378 * @ptype rowexpander
7380 Ext.ux.grid.RowExpander = Ext.extend(Ext.util.Observable, {
7381 <div id="cfg-Ext.ux.grid.RowExpander-expandOnEnter"></div>/**
7382 * @cfg {Boolean} expandOnEnter
7383 * <tt>true</tt> to toggle selected row(s) between expanded/collapsed when the enter
7384 * key is pressed (defaults to <tt>true</tt>).
7386 expandOnEnter : true,
7387 <div id="cfg-Ext.ux.grid.RowExpander-expandOnDblClick"></div>/**
7388 * @cfg {Boolean} expandOnDblClick
7389 * <tt>true</tt> to toggle a row between expanded/collapsed when double clicked
7390 * (defaults to <tt>true</tt>).
7392 expandOnDblClick : true,
7399 menuDisabled : true,
7403 enableCaching : true,
7405 constructor: function(config){
7406 Ext.apply(this, config);
7409 <div id="event-Ext.ux.grid.RowExpander-beforeexpand"></div>/**
7410 * @event beforeexpand
7411 * Fires before the row expands. Have the listener return false to prevent the row from expanding.
7412 * @param {Object} this RowExpander object.
7413 * @param {Object} Ext.data.Record Record for the selected row.
7414 * @param {Object} body body element for the secondary row.
7415 * @param {Number} rowIndex The current row index.
7418 <div id="event-Ext.ux.grid.RowExpander-expand"></div>/**
7420 * Fires after the row expands.
7421 * @param {Object} this RowExpander object.
7422 * @param {Object} Ext.data.Record Record for the selected row.
7423 * @param {Object} body body element for the secondary row.
7424 * @param {Number} rowIndex The current row index.
7427 <div id="event-Ext.ux.grid.RowExpander-beforecollapse"></div>/**
7428 * @event beforecollapse
7429 * Fires before the row collapses. Have the listener return false to prevent the row from collapsing.
7430 * @param {Object} this RowExpander object.
7431 * @param {Object} Ext.data.Record Record for the selected row.
7432 * @param {Object} body body element for the secondary row.
7433 * @param {Number} rowIndex The current row index.
7435 beforecollapse: true,
7436 <div id="event-Ext.ux.grid.RowExpander-collapse"></div>/**
7438 * Fires after the row collapses.
7439 * @param {Object} this RowExpander object.
7440 * @param {Object} Ext.data.Record Record for the selected row.
7441 * @param {Object} body body element for the secondary row.
7442 * @param {Number} rowIndex The current row index.
7447 Ext.ux.grid.RowExpander.superclass.constructor.call(this);
7450 if(typeof this.tpl == 'string'){
7451 this.tpl = new Ext.Template(this.tpl);
7457 this.bodyContent = {};
7460 getRowClass : function(record, rowIndex, p, ds){
7462 var content = this.bodyContent[record.id];
7463 if(!content && !this.lazyRender){
7464 content = this.getBodyContent(record, rowIndex);
7469 return this.state[record.id] ? 'x-grid3-row-expanded' : 'x-grid3-row-collapsed';
7472 init : function(grid){
7475 var view = grid.getView();
7476 view.getRowClass = this.getRowClass.createDelegate(this);
7478 view.enableRowBody = true;
7481 grid.on('render', this.onRender, this);
7482 grid.on('destroy', this.onDestroy, this);
7486 onRender: function() {
7487 var grid = this.grid;
7488 var mainBody = grid.getView().mainBody;
7489 mainBody.on('mousedown', this.onMouseDown, this, {delegate: '.x-grid3-row-expander'});
7490 if (this.expandOnEnter) {
7491 this.keyNav = new Ext.KeyNav(this.grid.getGridEl(), {
7492 'enter' : this.onEnter,
7496 if (this.expandOnDblClick) {
7497 grid.on('rowdblclick', this.onRowDblClick, this);
7502 onDestroy: function() {
7504 this.keyNav.disable();
7508 * A majority of the time, the plugin will be destroyed along with the grid,
7509 * which means the mainBody won't be available. On the off chance that the plugin
7510 * isn't destroyed with the grid, take care of removing the listener.
7512 var mainBody = this.grid.getView().mainBody;
7514 mainBody.un('mousedown', this.onMouseDown, this);
7518 onRowDblClick: function(grid, rowIdx, e) {
7519 this.toggleRow(rowIdx);
7522 onEnter: function(e) {
7524 var sm = g.getSelectionModel();
7525 var sels = sm.getSelections();
7526 for (var i = 0, len = sels.length; i < len; i++) {
7527 var rowIdx = g.getStore().indexOf(sels[i]);
7528 this.toggleRow(rowIdx);
7532 getBodyContent : function(record, index){
7533 if(!this.enableCaching){
7534 return this.tpl.apply(record.data);
7536 var content = this.bodyContent[record.id];
7538 content = this.tpl.apply(record.data);
7539 this.bodyContent[record.id] = content;
7544 onMouseDown : function(e, t){
7546 var row = e.getTarget('.x-grid3-row');
7547 this.toggleRow(row);
7550 renderer : function(v, p, record){
7551 p.cellAttr = 'rowspan="2"';
7552 return '<div class="x-grid3-row-expander"> </div>';
7555 beforeExpand : function(record, body, rowIndex){
7556 if(this.fireEvent('beforeexpand', this, record, body, rowIndex) !== false){
7557 if(this.tpl && this.lazyRender){
7558 body.innerHTML = this.getBodyContent(record, rowIndex);
7566 toggleRow : function(row){
7567 if(typeof row == 'number'){
7568 row = this.grid.view.getRow(row);
7570 this[Ext.fly(row).hasClass('x-grid3-row-collapsed') ? 'expandRow' : 'collapseRow'](row);
7573 expandRow : function(row){
7574 if(typeof row == 'number'){
7575 row = this.grid.view.getRow(row);
7577 var record = this.grid.store.getAt(row.rowIndex);
7578 var body = Ext.DomQuery.selectNode('tr:nth(2) div.x-grid3-row-body', row);
7579 if(this.beforeExpand(record, body, row.rowIndex)){
7580 this.state[record.id] = true;
7581 Ext.fly(row).replaceClass('x-grid3-row-collapsed', 'x-grid3-row-expanded');
7582 this.fireEvent('expand', this, record, body, row.rowIndex);
7586 collapseRow : function(row){
7587 if(typeof row == 'number'){
7588 row = this.grid.view.getRow(row);
7590 var record = this.grid.store.getAt(row.rowIndex);
7591 var body = Ext.fly(row).child('tr:nth(1) div.x-grid3-row-body', true);
7592 if(this.fireEvent('beforecollapse', this, record, body, row.rowIndex) !== false){
7593 this.state[record.id] = false;
7594 Ext.fly(row).replaceClass('x-grid3-row-expanded', 'x-grid3-row-collapsed');
7595 this.fireEvent('collapse', this, record, body, row.rowIndex);
7600 Ext.preg('rowexpander', Ext.ux.grid.RowExpander);
7603 Ext.grid.RowExpander = Ext.ux.grid.RowExpander;// We are adding these custom layouts to a namespace that does not
7604 // exist by default in Ext, so we have to add the namespace first:
7605 Ext.ns('Ext.ux.layout');
7607 <div id="cls-Ext.ux.layout.RowLayout"></div>/**
7608 * @class Ext.ux.layout.RowLayout
7609 * @extends Ext.layout.ContainerLayout
7610 * <p>This is the layout style of choice for creating structural layouts in a multi-row format where the height of
7611 * each row can be specified as a percentage or fixed height. Row widths can also be fixed, percentage or auto.
7612 * This class is intended to be extended or created via the layout:'ux.row' {@link Ext.Container#layout} config,
7613 * and should generally not need to be created directly via the new keyword.</p>
7614 * <p>RowLayout does not have any direct config options (other than inherited ones), but it does support a
7615 * specific config property of <b><tt>rowHeight</tt></b> that can be included in the config of any panel added to it. The
7616 * layout will use the rowHeight (if present) or height of each panel during layout to determine how to size each panel.
7617 * If height or rowHeight is not specified for a given panel, its height will default to the panel's height (or auto).</p>
7618 * <p>The height property is always evaluated as pixels, and must be a number greater than or equal to 1.
7619 * The rowHeight property is always evaluated as a percentage, and must be a decimal value greater than 0 and
7620 * less than 1 (e.g., .25).</p>
7621 * <p>The basic rules for specifying row heights are pretty simple. The logic makes two passes through the
7622 * set of contained panels. During the first layout pass, all panels that either have a fixed height or none
7623 * specified (auto) are skipped, but their heights are subtracted from the overall container height. During the second
7624 * pass, all panels with rowHeights are assigned pixel heights in proportion to their percentages based on
7625 * the total <b>remaining</b> container height. In other words, percentage height panels are designed to fill the space
7626 * left over by all the fixed-height and/or auto-height panels. Because of this, while you can specify any number of rows
7627 * with different percentages, the rowHeights must always add up to 1 (or 100%) when added together, otherwise your
7628 * layout may not render as expected. Example usage:</p>
7630 // All rows are percentages -- they must add up to 1
7631 var p = new Ext.Panel({
7632 title: 'Row Layout - Percentage Only',
7646 // Mix of height and rowHeight -- all rowHeight values must add
7647 // up to 1. The first row will take up exactly 120px, and the last two
7648 // rows will fill the remaining container height.
7649 var p = new Ext.Panel({
7650 title: 'Row Layout - Mixed',
7655 // standard panel widths are still supported too:
7656 width: '50%' // or 200
7668 Ext.ux.layout.RowLayout = Ext.extend(Ext.layout.ContainerLayout, {
7675 allowContainerRemove: false,
7678 isValidParent : function(c, target){
7679 return this.innerCt && c.getPositionEl().dom.parentNode == this.innerCt.dom;
7682 getLayoutTargetSize : function() {
7683 var target = this.container.getLayoutTarget(), ret;
7685 ret = target.getViewSize();
7687 // IE in strict mode will return a height of 0 on the 1st pass of getViewSize.
7688 // Use getStyleSize to verify the 0 height, the adjustment pass will then work properly
7690 if (Ext.isIE && Ext.isStrict && ret.height == 0){
7691 ret = target.getStyleSize();
7694 ret.width -= target.getPadding('lr');
7695 ret.height -= target.getPadding('tb');
7700 renderAll : function(ct, target) {
7702 // the innerCt prevents wrapping and shuffling while
7703 // the container is resizing
7704 this.innerCt = target.createChild({cls:'x-column-inner'});
7705 this.innerCt.createChild({cls:'x-clear'});
7707 Ext.layout.ColumnLayout.superclass.renderAll.call(this, ct, this.innerCt);
7711 onLayout : function(ct, target){
7712 var rs = ct.items.items,
7719 this.renderAll(ct, target);
7721 var size = this.getLayoutTargetSize();
7723 if(size.width < 1 && size.height < 1){ // display none?
7727 var h = size.height,
7730 this.innerCt.setSize({height:h});
7732 // some rows can be percentages while others are fixed
7733 // so we need to make 2 passes
7735 for(i = 0; i < len; i++){
7737 m = r.getPositionEl().getMargins('tb');
7740 ph -= (r.getHeight() + m);
7744 ph = ph < 0 ? 0 : ph;
7746 for(i = 0; i < len; i++){
7750 r.setSize({height: Math.floor(r.rowHeight*ph) - m});
7754 // Browsers differ as to when they account for scrollbars. We need to re-measure to see if the scrollbar
7755 // spaces were accounted for properly. If not, re-layout.
7757 if (i = target.getStyle('overflow') && i != 'hidden' && !this.adjustmentPass) {
7758 var ts = this.getLayoutTargetSize();
7759 if (ts.width != size.width){
7760 this.adjustmentPass = true;
7761 this.onLayout(ct, target);
7765 delete this.adjustmentPass;
7768 <div id="prop-Ext.ux.layout.RowLayout-activeItem"></div>/**
7769 * @property activeItem
7774 Ext.Container.LAYOUTS['ux.row'] = Ext.ux.layout.RowLayout;
7775 Ext.ns('Ext.ux.form');
7777 Ext.ux.form.SearchField = Ext.extend(Ext.form.TwinTriggerField, {
7778 initComponent : function(){
7779 Ext.ux.form.SearchField.superclass.initComponent.call(this);
7780 this.on('specialkey', function(f, e){
7781 if(e.getKey() == e.ENTER){
7782 this.onTrigger2Click();
7787 validationEvent:false,
7788 validateOnBlur:false,
7789 trigger1Class:'x-form-clear-trigger',
7790 trigger2Class:'x-form-search-trigger',
7794 paramName : 'query',
7796 onTrigger1Click : function(){
7798 this.el.dom.value = '';
7800 this.store.baseParams = this.store.baseParams || {};
7801 this.store.baseParams[this.paramName] = '';
7802 this.store.reload({params:o});
7803 this.triggers[0].hide();
7804 this.hasSearch = false;
7808 onTrigger2Click : function(){
7809 var v = this.getRawValue();
7811 this.onTrigger1Click();
7815 this.store.baseParams = this.store.baseParams || {};
7816 this.store.baseParams[this.paramName] = v;
7817 this.store.reload({params:o});
7818 this.hasSearch = true;
7819 this.triggers[0].show();
7821 });Ext.ns('Ext.ux.form');
7824 * @class Ext.ux.form.SelectBox
7825 * @extends Ext.form.ComboBox
7826 * <p>Makes a ComboBox more closely mimic an HTML SELECT. Supports clicking and dragging
7827 * through the list, with item selection occurring when the mouse button is released.
7828 * When used will automatically set {@link #editable} to false and call {@link Ext.Element#unselectable}
7829 * on inner elements. Re-enabling editable after calling this will NOT work.</p>
7830 * @author Corey Gilmore http://extjs.com/forum/showthread.php?t=6392
7831 * @history 2007-07-08 jvs
7832 * Slight mods for Ext 2.0
7835 Ext.ux.form.SelectBox = Ext.extend(Ext.form.ComboBox, {
7836 constructor: function(config){
7837 this.searchResetDelay = 1000;
7838 config = config || {};
7839 config = Ext.apply(config || {}, {
7841 forceSelection: true,
7843 lastSearchTerm: false,
7844 triggerAction: 'all',
7848 Ext.ux.form.SelectBox.superclass.constructor.apply(this, arguments);
7850 this.lastSelectedIndex = this.selectedIndex || 0;
7853 initEvents : function(){
7854 Ext.ux.form.SelectBox.superclass.initEvents.apply(this, arguments);
7855 // you need to use keypress to capture upper/lower case and shift+key, but it doesn't work in IE
7856 this.el.on('keydown', this.keySearch, this, true);
7857 this.cshTask = new Ext.util.DelayedTask(this.clearSearchHistory, this);
7860 keySearch : function(e, target, options) {
7861 var raw = e.getKey();
7862 var key = String.fromCharCode(raw);
7865 if( !this.store.getCount() ) {
7870 case Ext.EventObject.HOME:
7875 case Ext.EventObject.END:
7880 case Ext.EventObject.PAGEDOWN:
7881 this.selectNextPage();
7885 case Ext.EventObject.PAGEUP:
7886 this.selectPrevPage();
7891 // skip special keys other than the shift key
7892 if( (e.hasModifier() && !e.shiftKey) || e.isNavKeyPress() || e.isSpecialKey() ) {
7895 if( this.lastSearchTerm == key ) {
7896 startIndex = this.lastSelectedIndex;
7898 this.search(this.displayField, key, startIndex);
7899 this.cshTask.delay(this.searchResetDelay);
7902 onRender : function(ct, position) {
7903 this.store.on('load', this.calcRowsPerPage, this);
7904 Ext.ux.form.SelectBox.superclass.onRender.apply(this, arguments);
7905 if( this.mode == 'local' ) {
7907 this.calcRowsPerPage();
7911 onSelect : function(record, index, skipCollapse){
7912 if(this.fireEvent('beforeselect', this, record, index) !== false){
7913 this.setValue(record.data[this.valueField || this.displayField]);
7914 if( !skipCollapse ) {
7917 this.lastSelectedIndex = index + 1;
7918 this.fireEvent('select', this, record, index);
7922 afterRender : function() {
7923 Ext.ux.form.SelectBox.superclass.afterRender.apply(this, arguments);
7925 this.el.swallowEvent('mousedown', true);
7927 this.el.unselectable();
7928 this.innerList.unselectable();
7929 this.trigger.unselectable();
7930 this.innerList.on('mouseup', function(e, target, options) {
7931 if( target.id && target.id == this.innerList.id ) {
7937 this.innerList.on('mouseover', function(e, target, options) {
7938 if( target.id && target.id == this.innerList.id ) {
7941 this.lastSelectedIndex = this.view.getSelectedIndexes()[0] + 1;
7942 this.cshTask.delay(this.searchResetDelay);
7945 this.trigger.un('click', this.onTriggerClick, this);
7946 this.trigger.on('mousedown', function(e, target, options) {
7948 this.onTriggerClick();
7951 this.on('collapse', function(e, target, options) {
7952 Ext.getDoc().un('mouseup', this.collapseIf, this);
7955 this.on('expand', function(e, target, options) {
7956 Ext.getDoc().on('mouseup', this.collapseIf, this);
7960 clearSearchHistory : function() {
7961 this.lastSelectedIndex = 0;
7962 this.lastSearchTerm = false;
7965 selectFirst : function() {
7966 this.focusAndSelect(this.store.data.first());
7969 selectLast : function() {
7970 this.focusAndSelect(this.store.data.last());
7973 selectPrevPage : function() {
7974 if( !this.rowHeight ) {
7977 var index = Math.max(this.selectedIndex-this.rowsPerPage, 0);
7978 this.focusAndSelect(this.store.getAt(index));
7981 selectNextPage : function() {
7982 if( !this.rowHeight ) {
7985 var index = Math.min(this.selectedIndex+this.rowsPerPage, this.store.getCount() - 1);
7986 this.focusAndSelect(this.store.getAt(index));
7989 search : function(field, value, startIndex) {
7990 field = field || this.displayField;
7991 this.lastSearchTerm = value;
7992 var index = this.store.find.apply(this.store, arguments);
7993 if( index !== -1 ) {
7994 this.focusAndSelect(index);
7998 focusAndSelect : function(record) {
7999 var index = Ext.isNumber(record) ? record : this.store.indexOf(record);
8000 this.select(index, this.isExpanded());
8001 this.onSelect(this.store.getAt(index), index, this.isExpanded());
8004 calcRowsPerPage : function() {
8005 if( this.store.getCount() ) {
8006 this.rowHeight = Ext.fly(this.view.getNode(0)).getHeight();
8007 this.rowsPerPage = this.maxHeight / this.rowHeight;
8009 this.rowHeight = false;
8015 Ext.reg('selectbox', Ext.ux.form.SelectBox);
8018 Ext.ux.SelectBox = Ext.ux.form.SelectBox;
8019 <div id="prop-Ext.ux.form.SelectBox-SlidingPager"></div>/**
8020 * Plugin for PagingToolbar which replaces the textfield input with a slider
8022 Ext.ux.SlidingPager = Ext.extend(Object, {
8023 init : function(pbar){
8024 var idx = pbar.items.indexOf(pbar.inputItem);
8025 Ext.each(pbar.items.getRange(idx - 2, idx + 2), function(c){
8028 var slider = new Ext.Slider({
8032 plugins: new Ext.slider.Tip({
8033 getText : function(thumb) {
8034 return String.format('Page <b>{0}</b> of <b>{1}</b>', thumb.value, thumb.slider.maxValue);
8038 changecomplete: function(s, v){
8043 pbar.insert(idx + 1, slider);
8045 change: function(pb, data){
8046 slider.setMaxValue(data.pages);
8047 slider.setValue(data.activePage);
8051 });Ext.ns('Ext.ux.form');
8054 * @class Ext.ux.form.SpinnerField
8055 * @extends Ext.form.NumberField
8056 * Creates a field utilizing Ext.ux.Spinner
8057 * @xtype spinnerfield
8059 Ext.ux.form.SpinnerField = Ext.extend(Ext.form.NumberField, {
8062 autoSize: Ext.emptyFn,
8063 onBlur: Ext.emptyFn,
8064 adjustSize: Ext.BoxComponent.prototype.adjustSize,
8066 constructor: function(config) {
8067 var spinnerConfig = Ext.copyTo({}, config, 'incrementValue,alternateIncrementValue,accelerate,defaultValue,triggerClass,splitterClass');
8069 var spl = this.spinner = new Ext.ux.Spinner(spinnerConfig);
8071 var plugins = config.plugins
8072 ? (Ext.isArray(config.plugins)
8073 ? config.plugins.push(spl)
8074 : [config.plugins, spl])
8077 Ext.ux.form.SpinnerField.superclass.constructor.call(this, Ext.apply(config, {plugins: plugins}));
8081 getResizeEl: function(){
8086 getPositionEl: function(){
8091 alignErrorIcon: function(){
8093 this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);
8097 validateBlur: function(){
8102 Ext.reg('spinnerfield', Ext.ux.form.SpinnerField);
8105 Ext.form.SpinnerField = Ext.ux.form.SpinnerField;
8107 * @class Ext.ux.Spinner
8108 * @extends Ext.util.Observable
8109 * Creates a Spinner control utilized by Ext.ux.form.SpinnerField
8111 Ext.ux.Spinner = Ext.extend(Ext.util.Observable, {
8113 alternateIncrementValue: 5,
8114 triggerClass: 'x-form-spinner-trigger',
8115 splitterClass: 'x-form-spinner-splitter',
8116 alternateKey: Ext.EventObject.shiftKey,
8120 constructor: function(config){
8121 Ext.ux.Spinner.superclass.constructor.call(this, config);
8122 Ext.apply(this, config);
8123 this.mimicing = false;
8126 init: function(field){
8129 field.afterMethod('onRender', this.doRender, this);
8130 field.afterMethod('onEnable', this.doEnable, this);
8131 field.afterMethod('onDisable', this.doDisable, this);
8132 field.afterMethod('afterRender', this.doAfterRender, this);
8133 field.afterMethod('onResize', this.doResize, this);
8134 field.afterMethod('onFocus', this.doFocus, this);
8135 field.beforeMethod('onDestroy', this.doDestroy, this);
8138 doRender: function(ct, position){
8139 var el = this.el = this.field.getEl();
8143 f.wrap = this.wrap = el.wrap({
8144 cls: "x-form-field-wrap"
8148 this.wrap = f.wrap.addClass('x-form-field-wrap');
8151 this.trigger = this.wrap.createChild({
8153 src: Ext.BLANK_IMAGE_URL,
8154 cls: "x-form-trigger " + this.triggerClass
8158 this.wrap.setWidth(el.getWidth() + this.trigger.getWidth());
8161 this.splitter = this.wrap.createChild({
8163 cls: this.splitterClass,
8164 style: 'width:13px; height:2px;'
8166 this.splitter.setRight((Ext.isIE) ? 1 : 2).setTop(10).show();
8168 this.proxy = this.trigger.createProxy('', this.splitter, true);
8169 this.proxy.addClass("x-form-spinner-proxy");
8170 this.proxy.setStyle('left', '0px');
8171 this.proxy.setSize(14, 1);
8173 this.dd = new Ext.dd.DDProxy(this.splitter.dom.id, "SpinnerDrag", {
8174 dragElId: this.proxy.id
8181 doAfterRender: function(){
8183 if (Ext.isIE && this.el.getY() != (y = this.trigger.getY())) {
8189 doEnable: function(){
8191 this.disabled = false;
8192 this.wrap.removeClass(this.field.disabledClass);
8196 doDisable: function(){
8198 this.disabled = true;
8199 this.wrap.addClass(this.field.disabledClass);
8200 this.el.removeClass(this.field.disabledClass);
8204 doResize: function(w, h){
8205 if (typeof w == 'number') {
8206 this.el.setWidth(w - this.trigger.getWidth());
8208 this.wrap.setWidth(this.el.getWidth() + this.trigger.getWidth());
8211 doFocus: function(){
8212 if (!this.mimicing) {
8213 this.wrap.addClass('x-trigger-wrap-focus');
8214 this.mimicing = true;
8215 Ext.get(Ext.isIE ? document.body : document).on("mousedown", this.mimicBlur, this, {
8218 this.el.on('keydown', this.checkTab, this);
8223 checkTab: function(e){
8224 if (e.getKey() == e.TAB) {
8230 mimicBlur: function(e){
8231 if (!this.wrap.contains(e.target) && this.field.validateBlur(e)) {
8237 triggerBlur: function(){
8238 this.mimicing = false;
8239 Ext.get(Ext.isIE ? document.body : document).un("mousedown", this.mimicBlur, this);
8240 this.el.un("keydown", this.checkTab, this);
8241 this.field.beforeBlur();
8242 this.wrap.removeClass('x-trigger-wrap-focus');
8243 this.field.onBlur.call(this.field);
8246 initTrigger: function(){
8247 this.trigger.addClassOnOver('x-form-trigger-over');
8248 this.trigger.addClassOnClick('x-form-trigger-click');
8251 initSpinner: function(){
8252 this.field.addEvents({
8258 this.keyNav = new Ext.KeyNav(this.el, {
8264 "down": function(e){
8269 "pageUp": function(e){
8271 this.onSpinUpAlternate();
8274 "pageDown": function(e){
8276 this.onSpinDownAlternate();
8282 this.repeater = new Ext.util.ClickRepeater(this.trigger, {
8283 accelerate: this.accelerate
8285 this.field.mon(this.repeater, "click", this.onTriggerClick, this, {
8286 preventDefault: true
8289 this.field.mon(this.trigger, {
8290 mouseover: this.onMouseOver,
8291 mouseout: this.onMouseOut,
8292 mousemove: this.onMouseMove,
8293 mousedown: this.onMouseDown,
8294 mouseup: this.onMouseUp,
8296 preventDefault: true
8299 this.field.mon(this.wrap, "mousewheel", this.handleMouseWheel, this);
8301 this.dd.setXConstraint(0, 0, 10)
8302 this.dd.setYConstraint(1500, 1500, 10);
8303 this.dd.endDrag = this.endDrag.createDelegate(this);
8304 this.dd.startDrag = this.startDrag.createDelegate(this);
8305 this.dd.onDrag = this.onDrag.createDelegate(this);
8308 onMouseOver: function(){
8309 if (this.disabled) {
8312 var middle = this.getMiddle();
8313 this.tmpHoverClass = (Ext.EventObject.getPageY() < middle) ? 'x-form-spinner-overup' : 'x-form-spinner-overdown';
8314 this.trigger.addClass(this.tmpHoverClass);
8318 onMouseOut: function(){
8319 this.trigger.removeClass(this.tmpHoverClass);
8323 onMouseMove: function(){
8324 if (this.disabled) {
8327 var middle = this.getMiddle();
8328 if (((Ext.EventObject.getPageY() > middle) && this.tmpHoverClass == "x-form-spinner-overup") ||
8329 ((Ext.EventObject.getPageY() < middle) && this.tmpHoverClass == "x-form-spinner-overdown")) {
8334 onMouseDown: function(){
8335 if (this.disabled) {
8338 var middle = this.getMiddle();
8339 this.tmpClickClass = (Ext.EventObject.getPageY() < middle) ? 'x-form-spinner-clickup' : 'x-form-spinner-clickdown';
8340 this.trigger.addClass(this.tmpClickClass);
8344 onMouseUp: function(){
8345 this.trigger.removeClass(this.tmpClickClass);
8349 onTriggerClick: function(){
8350 if (this.disabled || this.el.dom.readOnly) {
8353 var middle = this.getMiddle();
8354 var ud = (Ext.EventObject.getPageY() < middle) ? 'Up' : 'Down';
8355 this['onSpin' + ud]();
8359 getMiddle: function(){
8360 var t = this.trigger.getTop();
8361 var h = this.trigger.getHeight();
8362 var middle = t + (h / 2);
8367 //checks if control is allowed to spin
8368 isSpinnable: function(){
8369 if (this.disabled || this.el.dom.readOnly) {
8370 Ext.EventObject.preventDefault(); //prevent scrolling when disabled/readonly
8376 handleMouseWheel: function(e){
8377 //disable scrolling when not focused
8378 if (this.wrap.hasClass('x-trigger-wrap-focus') == false) {
8382 var delta = e.getWheelDelta();
8395 startDrag: function(){
8397 this._previousY = Ext.fly(this.dd.getDragEl()).getTop();
8401 endDrag: function(){
8407 if (this.disabled) {
8410 var y = Ext.fly(this.dd.getDragEl()).getTop();
8413 if (this._previousY > y) {
8416 if (this._previousY < y) {
8420 this['onSpin' + ud]();
8423 this._previousY = y;
8427 onSpinUp: function(){
8428 if (this.isSpinnable() == false) {
8431 if (Ext.EventObject.shiftKey == true) {
8432 this.onSpinUpAlternate();
8436 this.spin(false, false);
8438 this.field.fireEvent("spin", this);
8439 this.field.fireEvent("spinup", this);
8443 onSpinDown: function(){
8444 if (this.isSpinnable() == false) {
8447 if (Ext.EventObject.shiftKey == true) {
8448 this.onSpinDownAlternate();
8452 this.spin(true, false);
8454 this.field.fireEvent("spin", this);
8455 this.field.fireEvent("spindown", this);
8459 onSpinUpAlternate: function(){
8460 if (this.isSpinnable() == false) {
8463 this.spin(false, true);
8464 this.field.fireEvent("spin", this);
8465 this.field.fireEvent("spinup", this);
8469 onSpinDownAlternate: function(){
8470 if (this.isSpinnable() == false) {
8473 this.spin(true, true);
8474 this.field.fireEvent("spin", this);
8475 this.field.fireEvent("spindown", this);
8478 spin: function(down, alternate){
8479 var v = parseFloat(this.field.getValue());
8480 var incr = (alternate == true) ? this.alternateIncrementValue : this.incrementValue;
8481 (down == true) ? v -= incr : v += incr;
8483 v = (isNaN(v)) ? this.defaultValue : v;
8484 v = this.fixBoundries(v);
8485 this.field.setRawValue(v);
8488 fixBoundries: function(value){
8491 if (this.field.minValue != undefined && v < this.field.minValue) {
8492 v = this.field.minValue;
8494 if (this.field.maxValue != undefined && v > this.field.maxValue) {
8495 v = this.field.maxValue;
8498 return this.fixPrecision(v);
8502 fixPrecision: function(value){
8503 var nan = isNaN(value);
8504 if (!this.field.allowDecimals || this.field.decimalPrecision == -1 || nan || !value) {
8505 return nan ? '' : value;
8507 return parseFloat(parseFloat(value).toFixed(this.field.decimalPrecision));
8510 doDestroy: function(){
8512 this.trigger.remove();
8516 delete this.field.wrap;
8519 if (this.splitter) {
8520 this.splitter.remove();
8529 this.proxy.remove();
8532 if (this.repeater) {
8533 this.repeater.purgeListeners();
8536 Ext.get(Ext.isIE ? document.body : document).un("mousedown", this.mimicBlur, this);
8542 Ext.form.Spinner = Ext.ux.Spinner;Ext.ux.Spotlight = function(config){
8543 Ext.apply(this, config);
8545 Ext.ux.Spotlight.prototype = {
8554 createElements : function(){
8555 var bd = Ext.getBody();
8557 this.right = bd.createChild({cls:'x-spotlight'});
8558 this.left = bd.createChild({cls:'x-spotlight'});
8559 this.top = bd.createChild({cls:'x-spotlight'});
8560 this.bottom = bd.createChild({cls:'x-spotlight'});
8562 this.all = new Ext.CompositeElement([this.right, this.left, this.top, this.bottom]);
8565 show : function(el, callback, scope){
8567 this.show.defer(50, this, [el, callback, scope]);
8570 this.el = Ext.get(el);
8572 this.createElements();
8575 this.all.setDisplayed('');
8576 this.applyBounds(true, false);
8578 Ext.EventManager.onWindowResize(this.syncSize, this);
8579 this.applyBounds(false, this.animate, false, callback, scope);
8581 this.applyBounds(false, false, false, callback, scope); // all these booleans look hideous
8585 hide : function(callback, scope){
8587 this.hide.defer(50, this, [callback, scope]);
8590 Ext.EventManager.removeResizeListener(this.syncSize, this);
8591 this.applyBounds(true, this.animate, true, callback, scope);
8594 doHide : function(){
8595 this.active = false;
8596 this.all.setDisplayed(false);
8599 syncSize : function(){
8600 this.applyBounds(false, false);
8603 applyBounds : function(basePts, anim, doHide, callback, scope){
8605 var rg = this.el.getRegion();
8607 var dw = Ext.lib.Dom.getViewWidth(true);
8608 var dh = Ext.lib.Dom.getViewHeight(true);
8610 var c = 0, cb = false;
8613 callback: function(){
8616 this.animated = false;
8620 Ext.callback(callback, scope, [this]);
8624 duration: this.duration,
8627 this.animated = true;
8630 this.right.setBounds(
8632 basePts ? dh : rg.top,
8634 basePts ? 0 : (dh - rg.top),
8637 this.left.setBounds(
8641 basePts ? 0 : rg.bottom,
8645 basePts ? dw : rg.left,
8647 basePts ? 0 : dw - rg.left,
8651 this.bottom.setBounds(
8654 basePts ? 0 : rg.right,
8663 Ext.callback(callback, scope, [this]);
8668 destroy : function(){
8681 Ext.Spotlight = Ext.ux.Spotlight;/**
8682 * @class Ext.ux.StatusBar
8683 * <p>Basic status bar component that can be used as the bottom toolbar of any {@link Ext.Panel}. In addition to
8684 * supporting the standard {@link Ext.Toolbar} interface for adding buttons, menus and other items, the StatusBar
8685 * provides a greedy status element that can be aligned to either side and has convenient methods for setting the
8686 * status text and icon. You can also indicate that something is processing using the {@link #showBusy} method.</p>
8691 bbar: new Ext.ux.StatusBar({
8694 // defaults to use when the status is cleared:
8695 defaultText: 'Default status text',
8696 defaultIconCls: 'default-icon',
8698 // values to set initially:
8700 iconCls: 'ready-icon',
8702 // any standard Toolbar items:
8705 }, '-', 'Plain Text']
8709 // Update the status bar later in code:
8710 var sb = Ext.getCmp('my-status');
8714 clear: true // auto-clear after a set interval
8717 // Set the status bar to show that something is processing:
8722 sb.clearStatus(); // once completeed
8724 * @extends Ext.Toolbar
8726 * Creates a new StatusBar
8727 * @param {Object/Array} config A config object
8729 Ext.ux.StatusBar = Ext.extend(Ext.Toolbar, {
8730 <div id="cfg-Ext.ux.StatusBar-statusAlign"></div>/**
8731 * @cfg {String} statusAlign
8732 * The alignment of the status element within the overall StatusBar layout. When the StatusBar is rendered,
8733 * it creates an internal div containing the status text and icon. Any additional Toolbar items added in the
8734 * StatusBar's {@link #items} config, or added via {@link #add} or any of the supported add* methods, will be
8735 * rendered, in added order, to the opposite side. The status element is greedy, so it will automatically
8736 * expand to take up all sapce left over by any other items. Example usage:
8738 // Create a left-aligned status bar containing a button,
8739 // separator and text item that will be right-aligned (default):
8743 bbar: new Ext.ux.StatusBar({
8744 defaultText: 'Default status text',
8748 }, '-', 'Plain Text']
8752 // By adding the statusAlign config, this will create the
8753 // exact same toolbar, except the status and toolbar item
8754 // layout will be reversed from the previous example:
8758 bbar: new Ext.ux.StatusBar({
8759 defaultText: 'Default status text',
8761 statusAlign: 'right',
8764 }, '-', 'Plain Text']
8769 <div id="cfg-Ext.ux.StatusBar-defaultText"></div>/**
8770 * @cfg {String} defaultText
8771 * The default {@link #text} value. This will be used anytime the status bar is cleared with the
8772 * <tt>useDefaults:true</tt> option (defaults to '').
8774 <div id="cfg-Ext.ux.StatusBar-defaultIconCls"></div>/**
8775 * @cfg {String} defaultIconCls
8776 * The default {@link #iconCls} value (see the iconCls docs for additional details about customizing the icon).
8777 * This will be used anytime the status bar is cleared with the <tt>useDefaults:true</tt> option (defaults to '').
8779 <div id="cfg-Ext.ux.StatusBar-text"></div>/**
8780 * @cfg {String} text
8781 * A string that will be <b>initially</b> set as the status message. This string
8782 * will be set as innerHTML (html tags are accepted) for the toolbar item.
8783 * If not specified, the value set for <code>{@link #defaultText}</code>
8786 <div id="cfg-Ext.ux.StatusBar-iconCls"></div>/**
8787 * @cfg {String} iconCls
8788 * A CSS class that will be <b>initially</b> set as the status bar icon and is
8789 * expected to provide a background image (defaults to '').
8790 * Example usage:<pre><code>
8791 // Example CSS rule:
8792 .x-statusbar .x-status-custom {
8794 background: transparent url(images/custom-icon.gif) no-repeat 3px 2px;
8797 // Setting a default icon:
8798 var sb = new Ext.ux.StatusBar({
8799 defaultIconCls: 'x-status-custom'
8802 // Changing the icon:
8805 iconCls: 'x-status-custom'
8810 <div id="cfg-Ext.ux.StatusBar-cls"></div>/**
8812 * The base class applied to the containing element for this component on render (defaults to 'x-statusbar')
8814 cls : 'x-statusbar',
8815 <div id="cfg-Ext.ux.StatusBar-busyIconCls"></div>/**
8816 * @cfg {String} busyIconCls
8817 * The default <code>{@link #iconCls}</code> applied when calling
8818 * <code>{@link #showBusy}</code> (defaults to <tt>'x-status-busy'</tt>).
8819 * It can be overridden at any time by passing the <code>iconCls</code>
8820 * argument into <code>{@link #showBusy}</code>.
8822 busyIconCls : 'x-status-busy',
8823 <div id="cfg-Ext.ux.StatusBar-busyText"></div>/**
8824 * @cfg {String} busyText
8825 * The default <code>{@link #text}</code> applied when calling
8826 * <code>{@link #showBusy}</code> (defaults to <tt>'Loading...'</tt>).
8827 * It can be overridden at any time by passing the <code>text</code>
8828 * argument into <code>{@link #showBusy}</code>.
8830 busyText : 'Loading...',
8831 <div id="cfg-Ext.ux.StatusBar-autoClear"></div>/**
8832 * @cfg {Number} autoClear
8833 * The number of milliseconds to wait after setting the status via
8834 * <code>{@link #setStatus}</code> before automatically clearing the status
8835 * text and icon (defaults to <tt>5000</tt>). Note that this only applies
8836 * when passing the <tt>clear</tt> argument to <code>{@link #setStatus}</code>
8837 * since that is the only way to defer clearing the status. This can
8838 * be overridden by specifying a different <tt>wait</tt> value in
8839 * <code>{@link #setStatus}</code>. Calls to <code>{@link #clearStatus}</code>
8840 * always clear the status bar immediately and ignore this value.
8844 <div id="cfg-Ext.ux.StatusBar-emptyText"></div>/**
8845 * @cfg {String} emptyText
8846 * The text string to use if no text has been set. Defaults to
8847 * <tt>' '</tt>). If there are no other items in the toolbar using
8848 * an empty string (<tt>''</tt>) for this value would end up in the toolbar
8849 * height collapsing since the empty string will not maintain the toolbar
8850 * height. Use <tt>''</tt> if the toolbar should collapse in height
8851 * vertically when no text is specified and there are no other items in
8854 emptyText : ' ',
8860 initComponent : function(){
8861 if(this.statusAlign=='right'){
8862 this.cls += ' x-status-right';
8864 Ext.ux.StatusBar.superclass.initComponent.call(this);
8868 afterRender : function(){
8869 Ext.ux.StatusBar.superclass.afterRender.call(this);
8871 var right = this.statusAlign == 'right';
8872 this.currIconCls = this.iconCls || this.defaultIconCls;
8873 this.statusEl = new Ext.Toolbar.TextItem({
8874 cls: 'x-status-text ' + (this.currIconCls || ''),
8875 text: this.text || this.defaultText || ''
8880 this.add(this.statusEl);
8882 this.insert(0, this.statusEl);
8883 this.insert(1, '->');
8888 <div id="method-Ext.ux.StatusBar-setStatus"></div>/**
8889 * Sets the status {@link #text} and/or {@link #iconCls}. Also supports automatically clearing the
8890 * status that was set after a specified interval.
8891 * @param {Object/String} config A config object specifying what status to set, or a string assumed
8892 * to be the status text (and all other options are defaulted as explained below). A config
8893 * object containing any or all of the following properties can be passed:<ul>
8894 * <li><tt>text</tt> {String} : (optional) The status text to display. If not specified, any current
8895 * status text will remain unchanged.</li>
8896 * <li><tt>iconCls</tt> {String} : (optional) The CSS class used to customize the status icon (see
8897 * {@link #iconCls} for details). If not specified, any current iconCls will remain unchanged.</li>
8898 * <li><tt>clear</tt> {Boolean/Number/Object} : (optional) Allows you to set an internal callback that will
8899 * automatically clear the status text and iconCls after a specified amount of time has passed. If clear is not
8900 * specified, the new status will not be auto-cleared and will stay until updated again or cleared using
8901 * {@link #clearStatus}. If <tt>true</tt> is passed, the status will be cleared using {@link #autoClear},
8902 * {@link #defaultText} and {@link #defaultIconCls} via a fade out animation. If a numeric value is passed,
8903 * it will be used as the callback interval (in milliseconds), overriding the {@link #autoClear} value.
8904 * All other options will be defaulted as with the boolean option. To customize any other options,
8905 * you can pass an object in the format:<ul>
8906 * <li><tt>wait</tt> {Number} : (optional) The number of milliseconds to wait before clearing
8907 * (defaults to {@link #autoClear}).</li>
8908 * <li><tt>anim</tt> {Number} : (optional) False to clear the status immediately once the callback
8909 * executes (defaults to true which fades the status out).</li>
8910 * <li><tt>useDefaults</tt> {Number} : (optional) False to completely clear the status text and iconCls
8911 * (defaults to true which uses {@link #defaultText} and {@link #defaultIconCls}).</li>
8913 * Example usage:<pre><code>
8914 // Simple call to update the text
8915 statusBar.setStatus('New status');
8917 // Set the status and icon, auto-clearing with default options:
8918 statusBar.setStatus({
8920 iconCls: 'x-status-custom',
8924 // Auto-clear with custom options:
8925 statusBar.setStatus({
8927 iconCls: 'x-status-custom',
8935 * @return {Ext.ux.StatusBar} this
8937 setStatus : function(o){
8940 if(typeof o == 'string'){
8943 if(o.text !== undefined){
8944 this.setText(o.text);
8946 if(o.iconCls !== undefined){
8947 this.setIcon(o.iconCls);
8952 wait = this.autoClear,
8953 defaults = {useDefaults: true, anim: true};
8955 if(typeof c == 'object'){
8956 c = Ext.applyIf(c, defaults);
8960 }else if(typeof c == 'number'){
8963 }else if(typeof c == 'boolean'){
8967 c.threadId = this.activeThreadId;
8968 this.clearStatus.defer(wait, this, [c]);
8973 <div id="method-Ext.ux.StatusBar-clearStatus"></div>/**
8974 * Clears the status {@link #text} and {@link #iconCls}. Also supports clearing via an optional fade out animation.
8975 * @param {Object} config (optional) A config object containing any or all of the following properties. If this
8976 * object is not specified the status will be cleared using the defaults below:<ul>
8977 * <li><tt>anim</tt> {Boolean} : (optional) True to clear the status by fading out the status element (defaults
8978 * to false which clears immediately).</li>
8979 * <li><tt>useDefaults</tt> {Boolean} : (optional) True to reset the text and icon using {@link #defaultText} and
8980 * {@link #defaultIconCls} (defaults to false which sets the text to '' and removes any existing icon class).</li>
8982 * @return {Ext.ux.StatusBar} this
8984 clearStatus : function(o){
8987 if(o.threadId && o.threadId !== this.activeThreadId){
8988 // this means the current call was made internally, but a newer
8989 // thread has set a message since this call was deferred. Since
8990 // we don't want to overwrite a newer message just ignore.
8994 var text = o.useDefaults ? this.defaultText : this.emptyText,
8995 iconCls = o.useDefaults ? (this.defaultIconCls ? this.defaultIconCls : '') : '';
8998 // animate the statusEl Ext.Element
8999 this.statusEl.el.fadeOut({
9003 callback: function(){
9009 this.statusEl.el.show();
9013 // hide/show the el to avoid jumpy text or icon
9014 this.statusEl.hide();
9019 this.statusEl.show();
9024 <div id="method-Ext.ux.StatusBar-setText"></div>/**
9025 * Convenience method for setting the status text directly. For more flexible options see {@link #setStatus}.
9026 * @param {String} text (optional) The text to set (defaults to '')
9027 * @return {Ext.ux.StatusBar} this
9029 setText : function(text){
9030 this.activeThreadId++;
9031 this.text = text || '';
9033 this.statusEl.setText(this.text);
9038 <div id="method-Ext.ux.StatusBar-getText"></div>/**
9039 * Returns the current status text.
9040 * @return {String} The status text
9042 getText : function(){
9046 <div id="method-Ext.ux.StatusBar-setIcon"></div>/**
9047 * Convenience method for setting the status icon directly. For more flexible options see {@link #setStatus}.
9048 * See {@link #iconCls} for complete details about customizing the icon.
9049 * @param {String} iconCls (optional) The icon class to set (defaults to '', and any current icon class is removed)
9050 * @return {Ext.ux.StatusBar} this
9052 setIcon : function(cls){
9053 this.activeThreadId++;
9057 if(this.currIconCls){
9058 this.statusEl.removeClass(this.currIconCls);
9059 this.currIconCls = null;
9062 this.statusEl.addClass(cls);
9063 this.currIconCls = cls;
9066 this.currIconCls = cls;
9071 <div id="method-Ext.ux.StatusBar-showBusy"></div>/**
9072 * Convenience method for setting the status text and icon to special values that are pre-configured to indicate
9073 * a "busy" state, usually for loading or processing activities.
9074 * @param {Object/String} config (optional) A config object in the same format supported by {@link #setStatus}, or a
9075 * string to use as the status text (in which case all other options for setStatus will be defaulted). Use the
9076 * <tt>text</tt> and/or <tt>iconCls</tt> properties on the config to override the default {@link #busyText}
9077 * and {@link #busyIconCls} settings. If the config argument is not specified, {@link #busyText} and
9078 * {@link #busyIconCls} will be used in conjunction with all of the default options for {@link #setStatus}.
9079 * @return {Ext.ux.StatusBar} this
9081 showBusy : function(o){
9082 if(typeof o == 'string'){
9085 o = Ext.applyIf(o || {}, {
9086 text: this.busyText,
9087 iconCls: this.busyIconCls
9089 return this.setStatus(o);
9092 Ext.reg('statusbar', Ext.ux.StatusBar);
9094 * @class Ext.ux.TabCloseMenu
9096 * Plugin (ptype = 'tabclosemenu') for adding a close context menu to tabs. Note that the menu respects
9097 * the closable configuration on the tab. As such, commands like remove others and remove all will not
9098 * remove items that are not closable.
9101 * @param {Object} config The configuration options
9102 * @ptype tabclosemenu
9104 Ext.ux.TabCloseMenu = Ext.extend(Object, {
9105 <div id="cfg-Ext.ux.TabCloseMenu-closeTabText"></div>/**
9106 * @cfg {String} closeTabText
9107 * The text for closing the current tab. Defaults to <tt>'Close Tab'</tt>.
9109 closeTabText: 'Close Tab',
9111 <div id="cfg-Ext.ux.TabCloseMenu-closeOtherTabsText"></div>/**
9112 * @cfg {String} closeOtherTabsText
9113 * The text for closing all tabs except the current one. Defaults to <tt>'Close Other Tabs'</tt>.
9115 closeOtherTabsText: 'Close Other Tabs',
9117 <div id="cfg-Ext.ux.TabCloseMenu-showCloseAll"></div>/**
9118 * @cfg {Boolean} showCloseAll
9119 * Indicates whether to show the 'Close All' option. Defaults to <tt>true</tt>.
9123 <div id="cfg-Ext.ux.TabCloseMenu-closeAllTabsText"></div>/**
9124 * @cfg {String} closeAllTabsText
9125 * <p>The text for closing all tabs. Defaults to <tt>'Close All Tabs'</tt>.
9127 closeAllTabsText: 'Close All Tabs',
9129 constructor : function(config){
9130 Ext.apply(this, config || {});
9134 init : function(tabs){
9138 contextmenu: this.onContextMenu,
9139 destroy: this.destroy
9143 destroy : function(){
9144 Ext.destroy(this.menu);
9151 onContextMenu : function(tabs, item, e){
9153 var m = this.createMenu(),
9155 disableOthers = true,
9156 closeAll = m.getComponent('closeall');
9158 m.getComponent('close').setDisabled(!item.closable);
9159 tabs.items.each(function(){
9163 disableOthers = false;
9168 m.getComponent('closeothers').setDisabled(disableOthers);
9170 closeAll.setDisabled(disableAll);
9174 m.showAt(e.getPoint());
9177 createMenu : function(){
9181 text: this.closeTabText,
9183 handler: this.onClose
9185 if(this.showCloseAll){
9189 itemId: 'closeothers',
9190 text: this.closeOtherTabsText,
9192 handler: this.onCloseOthers
9194 if(this.showCloseAll){
9197 text: this.closeAllTabsText,
9199 handler: this.onCloseAll
9202 this.menu = new Ext.menu.Menu({
9209 onClose : function(){
9210 this.tabs.remove(this.active);
9213 onCloseOthers : function(){
9217 onCloseAll : function(){
9218 this.doClose(false);
9221 doClose : function(excludeActive){
9223 this.tabs.items.each(function(item){
9225 if(!excludeActive || item != this.active){
9230 Ext.each(items, function(item){
9231 this.tabs.remove(item);
9236 Ext.preg('tabclosemenu', Ext.ux.TabCloseMenu);Ext.ns('Ext.ux.grid');
9238 <div id="cls-Ext.ux.grid.TableGrid"></div>/**
9239 * @class Ext.ux.grid.TableGrid
9240 * @extends Ext.grid.GridPanel
9241 * A Grid which creates itself from an existing HTML table element.
9243 * 2007-03-01 Original version by Nige "Animal" White
9244 * 2007-03-10 jvs Slightly refactored to reuse existing classes * @constructor
9245 * @param {String/HTMLElement/Ext.Element} table The table element from which this grid will be created -
9246 * The table MUST have some type of size defined for the grid to fill. The container will be
9247 * automatically set to position relative if it isn't already.
9248 * @param {Object} config A config object that sets properties on this grid and has two additional (optional)
9249 * properties: fields and columns which allow for customizing data fields and columns for this grid.
9251 Ext.ux.grid.TableGrid = function(table, config){
9254 Ext.apply(this, config);
9255 var cf = config.fields || [], ch = config.columns || [];
9256 table = Ext.get(table);
9258 var ct = table.insertSibling();
9260 var fields = [], cols = [];
9261 var headers = table.query("thead th");
9262 for (var i = 0, h; h = headers[i]; i++) {
9263 var text = h.innerHTML;
9264 var name = 'tcol-' + i;
9266 fields.push(Ext.applyIf(cf[i] ||
9269 mapping: 'td:nth(' + (i + 1) + ')/@innerHTML'
9272 cols.push(Ext.applyIf(ch[i] ||
9276 'width': h.offsetWidth,
9282 var ds = new Ext.data.Store({
9283 reader: new Ext.data.XmlReader({
9288 ds.loadData(table.dom);
9290 var cm = new Ext.grid.ColumnModel(cols);
9292 if (config.width || config.height) {
9293 ct.setSize(config.width || 'auto', config.height || 'auto');
9296 ct.setWidth(table.getWidth());
9299 if (config.remove !== false) {
9306 'sm': new Ext.grid.RowSelectionModel(),
9310 Ext.ux.grid.TableGrid.superclass.constructor.call(this, ct, {});
9313 Ext.extend(Ext.ux.grid.TableGrid, Ext.grid.GridPanel);
9316 Ext.grid.TableGrid = Ext.ux.grid.TableGrid;
9318 <div id="cls-Ext.ux.TabScrollerMenu"></div>/**
9319 * @class Ext.ux.TabScrollerMenu
9321 * Plugin (ptype = 'tabscrollermenu') for adding a tab scroller menu to tabs.
9323 * @param {Object} config Configuration options
9324 * @ptype tabscrollermenu
9326 Ext.ux.TabScrollerMenu = Ext.extend(Object, {
9327 <div id="cfg-Ext.ux.TabScrollerMenu-pageSize"></div>/**
9328 * @cfg {Number} pageSize How many items to allow per submenu.
9331 <div id="cfg-Ext.ux.TabScrollerMenu-maxText"></div>/**
9332 * @cfg {Number} maxText How long should the title of each {@link Ext.menu.Item} be.
9335 <div id="cfg-Ext.ux.TabScrollerMenu-menuPrefixText"></div>/**
9336 * @cfg {String} menuPrefixText Text to prefix the submenus.
9338 menuPrefixText : 'Items',
9339 constructor : function(config) {
9340 config = config || {};
9341 Ext.apply(this, config);
9344 init : function(tabPanel) {
9345 Ext.apply(tabPanel, this.parentOverrides);
9347 tabPanel.tabScrollerMenu = this;
9355 var newFn = tabPanel.createScrollers.createSequence(thisRef.createPanelsMenu, this);
9356 tabPanel.createScrollers = newFn;
9361 // private && sequeneced
9362 createPanelsMenu : function() {
9363 var h = this.stripWrap.dom.offsetHeight;
9365 //move the right menu item to the left 18px
9366 var rtScrBtn = this.header.dom.firstChild;
9367 Ext.fly(rtScrBtn).applyStyles({
9371 var stripWrap = Ext.get(this.strip.dom.parentNode);
9372 stripWrap.applyStyles({
9373 'margin-right' : '36px'
9376 // Add the new righthand menu
9377 var scrollMenu = this.header.insertFirst({
9378 cls:'x-tab-tabmenu-right'
9380 scrollMenu.setHeight(h);
9381 scrollMenu.addClassOnOver('x-tab-tabmenu-over');
9382 scrollMenu.on('click', this.showTabsMenu, this);
9384 this.scrollLeft.show = this.scrollLeft.show.createSequence(function() {
9388 this.scrollLeft.hide = this.scrollLeft.hide.createSequence(function() {
9393 <div id="method-Ext.ux.TabScrollerMenu-getPageSize"></div>/**
9394 * Returns an the current page size (this.pageSize);
9395 * @return {Number} this.pageSize The current page size.
9397 getPageSize : function() {
9398 return this.pageSize;
9400 <div id="method-Ext.ux.TabScrollerMenu-setPageSize"></div>/**
9401 * Sets the number of menu items per submenu "page size".
9402 * @param {Number} pageSize The page size
9404 setPageSize : function(pageSize) {
9405 this.pageSize = pageSize;
9407 <div id="method-Ext.ux.TabScrollerMenu-getMaxText"></div>/**
9408 * Returns the current maxText length;
9409 * @return {Number} this.maxText The current max text length.
9411 getMaxText : function() {
9412 return this.maxText;
9414 <div id="method-Ext.ux.TabScrollerMenu-setMaxText"></div>/**
9415 * Sets the maximum text size for each menu item.
9416 * @param {Number} t The max text per each menu item.
9418 setMaxText : function(t) {
9421 <div id="method-Ext.ux.TabScrollerMenu-getMenuPrefixText"></div>/**
9422 * Returns the current menu prefix text String.;
9423 * @return {String} this.menuPrefixText The current menu prefix text.
9425 getMenuPrefixText : function() {
9426 return this.menuPrefixText;
9428 <div id="method-Ext.ux.TabScrollerMenu-setMenuPrefixText"></div>/**
9429 * Sets the menu prefix text String.
9430 * @param {String} t The menu prefix text.
9432 setMenuPrefixText : function(t) {
9433 this.menuPrefixText = t;
9435 // private && applied to the tab panel itself.
9437 // all execute within the scope of the tab panel
9439 showTabsMenu : function(e) {
9440 if (this.tabsMenu) {
9441 this.tabsMenu.destroy();
9442 this.un('destroy', this.tabsMenu.destroy, this.tabsMenu);
9443 this.tabsMenu = null;
9445 this.tabsMenu = new Ext.menu.Menu();
9446 this.on('destroy', this.tabsMenu.destroy, this.tabsMenu);
9448 this.generateTabMenuItems();
9450 var target = Ext.get(e.getTarget());
9451 var xy = target.getXY();
9453 //Y param + 24 pixels
9456 this.tabsMenu.showAt(xy);
9459 generateTabMenuItems : function() {
9460 var curActive = this.getActiveTab();
9461 var totalItems = this.items.getCount();
9462 var pageSize = this.tabScrollerMenu.getPageSize();
9465 if (totalItems > pageSize) {
9466 var numSubMenus = Math.floor(totalItems / pageSize);
9467 var remainder = totalItems % pageSize;
9469 // Loop through all of the items and create submenus in chunks of 10
9470 for (var i = 0 ; i < numSubMenus; i++) {
9471 var curPage = (i + 1) * pageSize;
9475 for (var x = 0; x < pageSize; x++) {
9476 index = x + curPage - pageSize;
9477 var item = this.items.get(index);
9478 menuItems.push(this.autoGenMenuItem(item));
9482 text : this.tabScrollerMenu.getMenuPrefixText() + ' ' + (curPage - pageSize + 1) + ' - ' + curPage,
9488 if (remainder > 0) {
9489 var start = numSubMenus * pageSize;
9491 for (var i = start ; i < totalItems; i ++ ) {
9492 var item = this.items.get(i);
9493 menuItems.push(this.autoGenMenuItem(item));
9497 text : this.tabScrollerMenu.menuPrefixText + ' ' + (start + 1) + ' - ' + (start + menuItems.length),
9504 this.items.each(function(item) {
9505 if (item.id != curActive.id && !item.hidden) {
9506 this.tabsMenu.add(this.autoGenMenuItem(item));
9512 autoGenMenuItem : function(item) {
9513 var maxText = this.tabScrollerMenu.getMaxText();
9514 var text = Ext.util.Format.ellipsis(item.title, maxText);
9518 handler : this.showTabFromMenu,
9520 disabled : item.disabled,
9522 iconCls : item.iconCls
9527 showTabFromMenu : function(menuItem) {
9528 this.setActiveTab(menuItem.tabToShow);
9533 Ext.reg('tabscrollermenu', Ext.ux.TabScrollerMenu);
9534 Ext.ns('Ext.ux.tree');
9536 <div id="cls-Ext.ux.tree.XmlTreeLoader"></div>/**
9537 * @class Ext.ux.tree.XmlTreeLoader
9538 * @extends Ext.tree.TreeLoader
9539 * <p>A TreeLoader that can convert an XML document into a hierarchy of {@link Ext.tree.TreeNode}s.
9540 * Any text value included as a text node in the XML will be added to the parent node as an attribute
9541 * called <tt>innerText</tt>. Also, the tag name of each XML node will be added to the tree node as
9542 * an attribute called <tt>tagName</tt>.</p>
9543 * <p>By default, this class expects that your source XML will provide the necessary attributes on each
9544 * node as expected by the {@link Ext.tree.TreePanel} to display and load properly. However, you can
9545 * provide your own custom processing of node attributes by overriding the {@link #processNode} method
9546 * and modifying the attributes as needed before they are used to create the associated TreeNode.</p>
9548 * Creates a new XmlTreeloader.
9549 * @param {Object} config A config object containing config properties.
9551 Ext.ux.tree.XmlTreeLoader = Ext.extend(Ext.tree.TreeLoader, {
9552 <div id="prop-Ext.ux.tree.XmlTreeLoader-XML_NODE_ELEMENT"></div>/**
9553 * @property XML_NODE_ELEMENT
9554 * XML element node (value 1, read-only)
9557 XML_NODE_ELEMENT : 1,
9558 <div id="prop-Ext.ux.tree.XmlTreeLoader-XML_NODE_TEXT"></div>/**
9559 * @property XML_NODE_TEXT
9560 * XML text node (value 3, read-only)
9566 processResponse : function(response, node, callback){
9567 var xmlData = response.responseXML,
9568 root = xmlData.documentElement || xmlData;
9572 node.appendChild(this.parseXml(root));
9575 this.runCallback(callback, scope || node, [node]);
9577 this.handleFailure(response);
9582 parseXml : function(node) {
9584 Ext.each(node.childNodes, function(n){
9585 if(n.nodeType == this.XML_NODE_ELEMENT){
9586 var treeNode = this.createNode(n);
9587 if(n.childNodes.length > 0){
9588 var child = this.parseXml(n);
9589 if(typeof child == 'string'){
9590 treeNode.attributes.innerText = child;
9592 treeNode.appendChild(child);
9595 nodes.push(treeNode);
9597 else if(n.nodeType == this.XML_NODE_TEXT){
9598 var text = n.nodeValue.trim();
9599 if(text.length > 0){
9600 return nodes = text;
9609 createNode : function(node){
9611 tagName: node.tagName
9614 Ext.each(node.attributes, function(a){
9615 attr[a.nodeName] = a.nodeValue;
9618 this.processAttributes(attr);
9620 return Ext.ux.tree.XmlTreeLoader.superclass.createNode.call(this, attr);
9624 * Template method intended to be overridden by subclasses that need to provide
9625 * custom attribute processing prior to the creation of each TreeNode. This method
9626 * will be passed a config object containing existing TreeNode attribute name/value
9627 * pairs which can be modified as needed directly (no need to return the object).
9629 processAttributes: Ext.emptyFn
9633 Ext.ux.XmlTreeLoader = Ext.ux.tree.XmlTreeLoader;
9635 * @class Ext.ux.ValidationStatus
9636 * A {@link Ext.StatusBar} plugin that provides automatic error notification when the
9637 * associated form contains validation errors.
9638 * @extends Ext.Component
9640 * Creates a new ValiationStatus plugin
9641 * @param {Object} config A config object
9643 Ext.ux.ValidationStatus = Ext.extend(Ext.Component, {
9644 <div id="cfg-Ext.ux.ValidationStatus-errorIconCls"></div>/**
9645 * @cfg {String} errorIconCls
9646 * The {@link #iconCls} value to be applied to the status message when there is a
9647 * validation error. Defaults to <tt>'x-status-error'</tt>.
9649 errorIconCls : 'x-status-error',
9650 <div id="cfg-Ext.ux.ValidationStatus-errorListCls"></div>/**
9651 * @cfg {String} errorListCls
9652 * The css class to be used for the error list when there are validation errors.
9653 * Defaults to <tt>'x-status-error-list'</tt>.
9655 errorListCls : 'x-status-error-list',
9656 <div id="cfg-Ext.ux.ValidationStatus-validIconCls"></div>/**
9657 * @cfg {String} validIconCls
9658 * The {@link #iconCls} value to be applied to the status message when the form
9659 * validates. Defaults to <tt>'x-status-valid'</tt>.
9661 validIconCls : 'x-status-valid',
9663 <div id="cfg-Ext.ux.ValidationStatus-showText"></div>/**
9664 * @cfg {String} showText
9665 * The {@link #text} value to be applied when there is a form validation error.
9666 * Defaults to <tt>'The form has errors (click for details...)'</tt>.
9668 showText : 'The form has errors (click for details...)',
9669 <div id="cfg-Ext.ux.ValidationStatus-showText"></div>/**
9670 * @cfg {String} showText
9671 * The {@link #text} value to display when the error list is displayed.
9672 * Defaults to <tt>'Click again to hide the error list'</tt>.
9674 hideText : 'Click again to hide the error list',
9675 <div id="cfg-Ext.ux.ValidationStatus-submitText"></div>/**
9676 * @cfg {String} submitText
9677 * The {@link #text} value to be applied when the form is being submitted.
9678 * Defaults to <tt>'Saving...'</tt>.
9680 submitText : 'Saving...',
9683 init : function(sb){
9684 sb.on('render', function(){
9685 this.statusBar = sb;
9686 this.monitor = true;
9687 this.errors = new Ext.util.MixedCollection();
9688 this.listAlign = (sb.statusAlign=='right' ? 'br-tr?' : 'bl-tl?');
9691 this.form = Ext.getCmp(this.form).getForm();
9692 this.startMonitoring();
9693 this.form.on('beforeaction', function(f, action){
9694 if(action.type == 'submit'){
9695 // Ignore monitoring while submitting otherwise the field validation
9696 // events cause the status message to reset too early
9697 this.monitor = false;
9700 var startMonitor = function(){
9701 this.monitor = true;
9703 this.form.on('actioncomplete', startMonitor, this);
9704 this.form.on('actionfailed', startMonitor, this);
9706 }, this, {single:true});
9712 // Grab the statusEl after the first layout.
9713 sb.statusEl.getEl().on('click', this.onStatusClick, this, {buffer:200});
9724 startMonitoring : function(){
9725 this.form.items.each(function(f){
9726 f.on('invalid', this.onFieldValidation, this);
9727 f.on('valid', this.onFieldValidation, this);
9732 stopMonitoring : function(){
9733 this.form.items.each(function(f){
9734 f.un('invalid', this.onFieldValidation, this);
9735 f.un('valid', this.onFieldValidation, this);
9740 onDestroy : function(){
9741 this.stopMonitoring();
9742 this.statusBar.statusEl.un('click', this.onStatusClick, this);
9743 Ext.ux.ValidationStatus.superclass.onDestroy.call(this);
9747 onFieldValidation : function(f, msg){
9752 this.errors.add(f.id, {field:f, msg:msg});
9754 this.errors.removeKey(f.id);
9756 this.updateErrorList();
9757 if(this.errors.getCount() > 0){
9758 if(this.statusBar.getText() != this.showText){
9759 this.statusBar.setStatus({text:this.showText, iconCls:this.errorIconCls});
9762 this.statusBar.clearStatus().setIcon(this.validIconCls);
9767 updateErrorList : function(){
9768 if(this.errors.getCount() > 0){
9770 this.errors.each(function(err){
9771 msg += ('<li id="x-err-'+ err.field.id +'"><a href="#">' + err.msg + '</a></li>');
9773 this.getMsgEl().update(msg+'</ul>');
9775 this.getMsgEl().update('');
9780 getMsgEl : function(){
9782 this.msgEl = Ext.DomHelper.append(Ext.getBody(), {
9783 cls: this.errorListCls+' x-hide-offsets'
9786 this.msgEl.on('click', function(e){
9787 var t = e.getTarget('li', 10, true);
9789 Ext.getCmp(t.id.split('x-err-')[1]).focus();
9792 }, this, {stopEvent:true}); // prevent anchor click navigation
9798 showErrors : function(){
9799 this.updateErrorList();
9800 this.getMsgEl().alignTo(this.statusBar.getEl(), this.listAlign).slideIn('b', {duration:0.3, easing:'easeOut'});
9801 this.statusBar.setText(this.hideText);
9802 this.form.getEl().on('click', this.hideErrors, this, {single:true}); // hide if the user clicks directly into the form
9806 hideErrors : function(){
9807 var el = this.getMsgEl();
9809 el.slideOut('b', {duration:0.2, easing:'easeIn'});
9810 this.statusBar.setText(this.showText);
9812 this.form.getEl().un('click', this.hideErrors, this);
9816 onStatusClick : function(){
9817 if(this.getMsgEl().isVisible()){
9819 }else if(this.errors.getCount() > 0){
9824 Ext.override(Ext.list.Column, {
9826 var types = Ext.data.Types,
9830 if(Ext.isString(this.type)){
9831 this.type = Ext.data.Types[this.type.toUpperCase()] || types.AUTO;
9834 this.type = types.AUTO;
9837 // named sortTypes are supported, here we look them up
9838 if(Ext.isString(st)){
9839 this.sortType = Ext.data.SortTypes[st];
9840 }else if(Ext.isEmpty(st)){
9841 this.sortType = this.type.sortType;
9846 Ext.tree.Column = Ext.extend(Ext.list.Column, {});
9847 Ext.tree.NumberColumn = Ext.extend(Ext.list.NumberColumn, {});
9848 Ext.tree.DateColumn = Ext.extend(Ext.list.DateColumn, {});
9849 Ext.tree.BooleanColumn = Ext.extend(Ext.list.BooleanColumn, {});
9851 Ext.reg('tgcolumn', Ext.tree.Column);
9852 Ext.reg('tgnumbercolumn', Ext.tree.NumberColumn);
9853 Ext.reg('tgdatecolumn', Ext.tree.DateColumn);
9854 Ext.reg('tgbooleancolumn', Ext.tree.BooleanColumn);
9857 * @class Ext.ux.tree.TreeGridNodeUI
9858 * @extends Ext.tree.TreeNodeUI
9860 Ext.ux.tree.TreeGridNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
9861 isTreeGridNodeUI: true,
9863 renderElements : function(n, a, targetNode, bulkRender){
9864 var t = n.getOwnerTree(),
9869 this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
9872 '<tbody class="x-tree-node">',
9873 '<tr ext:tree-node-id="', n.id ,'" class="x-tree-node-el x-tree-node-leaf ', a.cls, '">',
9874 '<td class="x-treegrid-col">',
9875 '<span class="x-tree-node-indent">', this.indentMarkup, "</span>",
9876 '<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow" />',
9877 '<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon', (a.icon ? " x-tree-node-inline-icon" : ""), (a.iconCls ? " "+a.iconCls : ""), '" unselectable="on" />',
9878 '<a hidefocus="on" class="x-tree-node-anchor" href="', a.href ? a.href : '#', '" tabIndex="1" ',
9879 a.hrefTarget ? ' target="'+a.hrefTarget+'"' : '', '>',
9880 '<span unselectable="on">', (c.tpl ? c.tpl.apply(a) : a[c.dataIndex] || c.text), '</span></a>',
9884 for(i = 1, len = cols.length; i < len; i++){
9887 '<td class="x-treegrid-col ', (c.cls ? c.cls : ''), '">',
9888 '<div unselectable="on" class="x-treegrid-text"', (c.align ? ' style="text-align: ' + c.align + ';"' : ''), '>',
9889 (c.tpl ? c.tpl.apply(a) : a[c.dataIndex]),
9896 '</tr><tr class="x-tree-node-ct"><td colspan="', cols.length, '">',
9897 '<table class="x-treegrid-node-ct-table" cellpadding="0" cellspacing="0" style="table-layout: fixed; display: none; width: ', t.innerCt.getWidth() ,'px;"><colgroup>'
9899 for(i = 0, len = cols.length; i<len; i++) {
9900 buf.push('<col style="width: ', (cols[i].hidden ? 0 : cols[i].width) ,'px;" />');
9902 buf.push('</colgroup></table></td></tr></tbody>');
9904 if(bulkRender !== true && n.nextSibling && n.nextSibling.ui.getEl()){
9905 this.wrap = Ext.DomHelper.insertHtml("beforeBegin", n.nextSibling.ui.getEl(), buf.join(''));
9907 this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf.join(''));
9910 this.elNode = this.wrap.childNodes[0];
9911 this.ctNode = this.wrap.childNodes[1].firstChild.firstChild;
9912 var cs = this.elNode.firstChild.childNodes;
9913 this.indentNode = cs[0];
9914 this.ecNode = cs[1];
9915 this.iconNode = cs[2];
9916 this.anchor = cs[3];
9917 this.textNode = cs[3].firstChild;
9921 animExpand : function(cb){
9922 this.ctNode.style.display = "";
9923 Ext.ux.tree.TreeGridNodeUI.superclass.animExpand.call(this, cb);
9927 Ext.ux.tree.TreeGridRootNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
9928 isTreeGridNodeUI: true,
9931 render : function(){
9933 this.wrap = this.ctNode = this.node.ownerTree.innerCt.dom;
9934 this.node.expanded = true;
9938 // weird table-layout: fixed issue in webkit
9939 var ct = this.ctNode;
9940 ct.style.tableLayout = null;
9942 ct.style.tableLayout = 'fixed';
9947 destroy : function(){
9949 Ext.dd.Registry.unregister(this.elNode.id);
9954 collapse : Ext.emptyFn,
9955 expand : Ext.emptyFn
9957 * @class Ext.tree.ColumnResizer
9958 * @extends Ext.util.Observable
9960 Ext.tree.ColumnResizer = Ext.extend(Ext.util.Observable, {
9961 <div id="cfg-Ext.tree.ColumnResizer-minWidth"></div>/**
9962 * @cfg {Number} minWidth The minimum width the column can be dragged to.
9963 * Defaults to <tt>14</tt>.
9967 constructor: function(config){
9968 Ext.apply(this, config);
9969 Ext.tree.ColumnResizer.superclass.constructor.call(this);
9972 init : function(tree){
9974 tree.on('render', this.initEvents, this);
9977 initEvents : function(tree){
9978 tree.mon(tree.innerHd, 'mousemove', this.handleHdMove, this);
9979 this.tracker = new Ext.dd.DragTracker({
9980 onBeforeStart: this.onBeforeStart.createDelegate(this),
9981 onStart: this.onStart.createDelegate(this),
9982 onDrag: this.onDrag.createDelegate(this),
9983 onEnd: this.onEnd.createDelegate(this),
9987 this.tracker.initEl(tree.innerHd);
9988 tree.on('beforedestroy', this.tracker.destroy, this.tracker);
9991 handleHdMove : function(e, t){
9994 hd = e.getTarget('.x-treegrid-hd', 3, true);
9997 var r = hd.getRegion(),
9999 pn = hd.dom.parentNode;
10001 if(x - r.left <= hw && hd.dom !== pn.firstChild) {
10002 var ps = hd.dom.previousSibling;
10003 while(ps && Ext.fly(ps).hasClass('x-treegrid-hd-hidden')) {
10004 ps = ps.previousSibling;
10007 this.activeHd = Ext.get(ps);
10008 ss.cursor = Ext.isWebKit ? 'e-resize' : 'col-resize';
10010 } else if(r.right - x <= hw) {
10012 while(ns && Ext.fly(ns).hasClass('x-treegrid-hd-hidden')) {
10013 ns = ns.previousSibling;
10016 this.activeHd = Ext.get(ns);
10017 ss.cursor = Ext.isWebKit ? 'w-resize' : 'col-resize';
10020 delete this.activeHd;
10026 onBeforeStart : function(e){
10027 this.dragHd = this.activeHd;
10028 return !!this.dragHd;
10031 onStart : function(e){
10032 this.dragHeadersDisabled = this.tree.headersDisabled;
10033 this.tree.headersDisabled = true;
10034 this.proxy = this.tree.body.createChild({cls:'x-treegrid-resizer'});
10035 this.proxy.setHeight(this.tree.body.getHeight());
10037 var x = this.tracker.getXY()[0];
10039 this.hdX = this.dragHd.getX();
10040 this.hdIndex = this.tree.findHeaderIndex(this.dragHd);
10042 this.proxy.setX(this.hdX);
10043 this.proxy.setWidth(x-this.hdX);
10045 this.maxWidth = this.tree.outerCt.getWidth() - this.tree.innerBody.translatePoints(this.hdX).left;
10048 onDrag : function(e){
10049 var cursorX = this.tracker.getXY()[0];
10050 this.proxy.setWidth((cursorX-this.hdX).constrain(this.minWidth, this.maxWidth));
10053 onEnd : function(e){
10054 var nw = this.proxy.getWidth(),
10056 disabled = this.dragHeadersDisabled;
10058 this.proxy.remove();
10059 delete this.dragHd;
10061 tree.columns[this.hdIndex].width = nw;
10062 tree.updateColumnWidths();
10064 setTimeout(function(){
10065 tree.headersDisabled = disabled;
10068 });Ext.ns('Ext.ux.tree');
10071 * @class Ext.ux.tree.TreeGridSorter
10072 * @extends Ext.tree.TreeSorter
10073 * Provides sorting of nodes in a {@link Ext.ux.tree.TreeGrid}. The TreeGridSorter automatically monitors events on the
10074 * associated TreeGrid that might affect the tree's sort order (beforechildrenrendered, append, insert and textchange).
10075 * Example usage:<br />
10077 new Ext.ux.tree.TreeGridSorter(myTreeGrid, {
10080 sortType: function(node) {
10081 // sort by a custom, typed attribute:
10082 return parseInt(node.id, 10);
10087 * @param {TreeGrid} tree
10088 * @param {Object} config
10090 Ext.ux.tree.TreeGridSorter = Ext.extend(Ext.tree.TreeSorter, {
10091 <div id="cfg-Ext.ux.tree.TreeGridSorter-sortClasses"></div>/**
10092 * @cfg {Array} sortClasses The CSS classes applied to a header when it is sorted. (defaults to <tt>['sort-asc', 'sort-desc']</tt>)
10094 sortClasses : ['sort-asc', 'sort-desc'],
10095 <div id="cfg-Ext.ux.tree.TreeGridSorter-sortAscText"></div>/**
10096 * @cfg {String} sortAscText The text displayed in the 'Sort Ascending' menu item (defaults to <tt>'Sort Ascending'</tt>)
10098 sortAscText : 'Sort Ascending',
10099 <div id="cfg-Ext.ux.tree.TreeGridSorter-sortDescText"></div>/**
10100 * @cfg {String} sortDescText The text displayed in the 'Sort Descending' menu item (defaults to <tt>'Sort Descending'</tt>)
10102 sortDescText : 'Sort Descending',
10104 constructor : function(tree, config) {
10105 if(!Ext.isObject(config)) {
10107 property: tree.columns[0].dataIndex || 'text',
10112 Ext.ux.tree.TreeGridSorter.superclass.constructor.apply(this, arguments);
10115 tree.on('headerclick', this.onHeaderClick, this);
10116 tree.ddAppendOnly = true;
10119 this.defaultSortFn = function(n1, n2){
10121 var desc = me.dir && me.dir.toLowerCase() == 'desc',
10122 prop = me.property || 'text',
10123 sortType = me.sortType,
10124 caseSensitive = me.caseSensitive === true,
10125 leafAttr = me.leafAttr || 'leaf',
10126 attr1 = n1.attributes,
10127 attr2 = n2.attributes;
10130 if(attr1[leafAttr] && !attr2[leafAttr]){
10133 if(!attr1[leafAttr] && attr2[leafAttr]){
10137 var prop1 = attr1[prop],
10138 prop2 = attr2[prop],
10139 v1 = sortType ? sortType(prop1) : (caseSensitive ? prop1 : prop1.toUpperCase());
10140 v2 = sortType ? sortType(prop2) : (caseSensitive ? prop2 : prop2.toUpperCase());
10143 return desc ? +1 : -1;
10145 return desc ? -1 : +1;
10151 tree.on('afterrender', this.onAfterTreeRender, this, {single: true});
10152 tree.on('headermenuclick', this.onHeaderMenuClick, this);
10155 onAfterTreeRender : function() {
10156 if(this.tree.hmenu){
10157 this.tree.hmenu.insert(0,
10158 {itemId:'asc', text: this.sortAscText, cls: 'xg-hmenu-sort-asc'},
10159 {itemId:'desc', text: this.sortDescText, cls: 'xg-hmenu-sort-desc'}
10162 this.updateSortIcon(0, 'asc');
10165 onHeaderMenuClick : function(c, id, index) {
10166 if(id === 'asc' || id === 'desc') {
10167 this.onHeaderClick(c, null, index);
10172 onHeaderClick : function(c, el, i) {
10173 if(c && !this.tree.headersDisabled){
10176 me.property = c.dataIndex;
10177 me.dir = c.dir = (c.dir === 'desc' ? 'asc' : 'desc');
10178 me.sortType = c.sortType;
10179 me.caseSensitive === Ext.isBoolean(c.caseSensitive) ? c.caseSensitive : this.caseSensitive;
10180 me.sortFn = c.sortFn || this.defaultSortFn;
10182 this.tree.root.cascade(function(n) {
10184 me.updateSort(me.tree, n);
10188 this.updateSortIcon(i, c.dir);
10193 updateSortIcon : function(col, dir){
10194 var sc = this.sortClasses,
10195 hds = this.tree.innerHd.select('td').removeClass(sc);
10196 hds.item(col).addClass(sc[dir == 'desc' ? 1 : 0]);
10199 * @class Ext.ux.tree.TreeGridLoader
10200 * @extends Ext.tree.TreeLoader
10202 Ext.ux.tree.TreeGridLoader = Ext.extend(Ext.tree.TreeLoader, {
10203 createNode : function(attr) {
10204 if (!attr.uiProvider) {
10205 attr.uiProvider = Ext.ux.tree.TreeGridNodeUI;
10207 return Ext.tree.TreeLoader.prototype.createNode.call(this, attr);
10210 * @class Ext.ux.tree.TreeGrid
10211 * @extends Ext.tree.TreePanel
10215 Ext.ux.tree.TreeGrid = Ext.extend(Ext.tree.TreePanel, {
10216 rootVisible : false,
10219 borderWidth : Ext.isBorderBox ? 0 : 2, // the combined left/right border for each cell
10220 cls : 'x-treegrid',
10222 columnResize : true,
10224 reserveScrollOffset : true,
10225 enableHdMenu : true,
10227 columnsText : 'Columns',
10229 initComponent : function() {
10231 this.root = new Ext.tree.AsyncTreeNode({text: 'Root'});
10234 // initialize the loader
10235 var l = this.loader;
10237 l = new Ext.ux.tree.TreeGridLoader({
10238 dataUrl: this.dataUrl,
10239 requestMethod: this.requestMethod,
10242 }else if(Ext.isObject(l) && !l.load){
10243 l = new Ext.ux.tree.TreeGridLoader(l);
10247 Ext.ux.tree.TreeGrid.superclass.initComponent.call(this);
10249 this.initColumns();
10251 if(this.enableSort) {
10252 this.treeGridSorter = new Ext.ux.tree.TreeGridSorter(this, this.enableSort);
10255 if(this.columnResize){
10256 this.colResizer = new Ext.tree.ColumnResizer(this.columnResize);
10257 this.colResizer.init(this);
10260 var c = this.columns;
10261 if(!this.internalTpl){
10262 this.internalTpl = new Ext.XTemplate(
10263 '<div class="x-grid3-header">',
10264 '<div class="x-treegrid-header-inner">',
10265 '<div class="x-grid3-header-offset">',
10266 '<table style="table-layout: fixed;" cellspacing="0" cellpadding="0" border="0"><colgroup><tpl for="columns"><col /></tpl></colgroup>',
10267 '<thead><tr class="x-grid3-hd-row">',
10268 '<tpl for="columns">',
10269 '<td class="x-grid3-hd x-grid3-cell x-treegrid-hd" style="text-align: {align};" id="', this.id, '-xlhd-{#}">',
10270 '<div class="x-grid3-hd-inner x-treegrid-hd-inner" unselectable="on">',
10271 this.enableHdMenu ? '<a class="x-grid3-hd-btn" href="#"></a>' : '',
10272 '{header}<img class="x-grid3-sort-icon" src="', Ext.BLANK_IMAGE_URL, '" />',
10279 '<div class="x-treegrid-root-node">',
10280 '<table class="x-treegrid-root-table" cellpadding="0" cellspacing="0" style="table-layout: fixed;"></table>',
10285 if(!this.colgroupTpl) {
10286 this.colgroupTpl = new Ext.XTemplate(
10287 '<colgroup><tpl for="columns"><col style="width: {width}px"/></tpl></colgroup>'
10292 initColumns : function() {
10293 var cs = this.columns,
10298 for(i = 0; i < len; i++){
10301 c.xtype = c.xtype ? (/^tg/.test(c.xtype) ? c.xtype : 'tg' + c.xtype) : 'tgcolumn';
10307 if(this.enableSort !== false && c.sortable !== false) {
10309 this.enableSort = true;
10313 this.columns = columns;
10316 onRender : function(){
10317 Ext.tree.TreePanel.superclass.onRender.apply(this, arguments);
10319 this.el.addClass('x-treegrid');
10321 this.outerCt = this.body.createChild({
10322 cls:'x-tree-root-ct x-treegrid-ct ' + (this.useArrows ? 'x-tree-arrows' : this.lines ? 'x-tree-lines' : 'x-tree-no-lines')
10325 this.internalTpl.overwrite(this.outerCt, {columns: this.columns});
10327 this.mainHd = Ext.get(this.outerCt.dom.firstChild);
10328 this.innerHd = Ext.get(this.mainHd.dom.firstChild);
10329 this.innerBody = Ext.get(this.outerCt.dom.lastChild);
10330 this.innerCt = Ext.get(this.innerBody.dom.firstChild);
10332 this.colgroupTpl.insertFirst(this.innerCt, {columns: this.columns});
10334 if(this.hideHeaders){
10335 this.el.child('.x-grid3-header').setDisplayed('none');
10337 else if(this.enableHdMenu !== false){
10338 this.hmenu = new Ext.menu.Menu({id: this.id + '-hctx'});
10339 if(this.enableColumnHide !== false){
10340 this.colMenu = new Ext.menu.Menu({id: this.id + '-hcols-menu'});
10343 beforeshow: this.beforeColMenuShow,
10344 itemclick: this.handleHdMenuClick
10348 hideOnClick: false,
10349 text: this.columnsText,
10350 menu: this.colMenu,
10351 iconCls: 'x-cols-icon'
10354 this.hmenu.on('itemclick', this.handleHdMenuClick, this);
10358 setRootNode : function(node){
10359 node.attributes.uiProvider = Ext.ux.tree.TreeGridRootNodeUI;
10360 node = Ext.ux.tree.TreeGrid.superclass.setRootNode.call(this, node);
10362 this.colgroupTpl.insertFirst(this.innerCt, {columns: this.columns});
10367 clearInnerCt : function(){
10369 var dom = this.innerCt.dom;
10370 while(dom.firstChild){
10371 dom.removeChild(dom.firstChild);
10374 Ext.ux.tree.TreeGrid.superclass.clearInnerCt.call(this);
10378 initEvents : function() {
10379 Ext.ux.tree.TreeGrid.superclass.initEvents.apply(this, arguments);
10381 this.mon(this.innerBody, 'scroll', this.syncScroll, this);
10382 this.mon(this.innerHd, 'click', this.handleHdDown, this);
10383 this.mon(this.mainHd, {
10385 mouseover: this.handleHdOver,
10386 mouseout: this.handleHdOut
10390 onResize : function(w, h) {
10391 Ext.ux.tree.TreeGrid.superclass.onResize.apply(this, arguments);
10393 var bd = this.innerBody.dom;
10394 var hd = this.innerHd.dom;
10400 if(Ext.isNumber(h)){
10401 bd.style.height = this.body.getHeight(true) - hd.offsetHeight + 'px';
10404 if(Ext.isNumber(w)){
10405 var sw = Ext.num(this.scrollOffset, Ext.getScrollBarWidth());
10406 if(this.reserveScrollOffset || ((bd.offsetWidth - bd.clientWidth) > 10)){
10407 this.setScrollOffset(sw);
10410 setTimeout(function(){
10411 me.setScrollOffset(bd.offsetWidth - bd.clientWidth > 10 ? sw : 0);
10417 updateColumnWidths : function() {
10418 var cols = this.columns,
10419 colCount = cols.length,
10420 groups = this.outerCt.query('colgroup'),
10421 groupCount = groups.length,
10424 for(i = 0; i<colCount; i++) {
10426 for(j = 0; j<groupCount; j++) {
10428 g.childNodes[i].style.width = (c.hidden ? 0 : c.width) + 'px';
10432 for(i = 0, groups = this.innerHd.query('td'), len = groups.length; i<len; i++) {
10433 c = Ext.fly(groups[i]);
10434 if(cols[i] && cols[i].hidden) {
10435 c.addClass('x-treegrid-hd-hidden');
10438 c.removeClass('x-treegrid-hd-hidden');
10442 var tcw = this.getTotalColumnWidth();
10443 Ext.fly(this.innerHd.dom.firstChild).setWidth(tcw + (this.scrollOffset || 0));
10444 this.outerCt.select('table').setWidth(tcw);
10445 this.syncHeaderScroll();
10448 getVisibleColumns : function() {
10454 for(i = 0; i<len; i++) {
10455 if(!cs[i].hidden) {
10456 columns.push(cs[i]);
10462 getTotalColumnWidth : function() {
10464 for(var i = 0, cs = this.getVisibleColumns(), len = cs.length; i<len; i++) {
10465 total += cs[i].width;
10470 setScrollOffset : function(scrollOffset) {
10471 this.scrollOffset = scrollOffset;
10472 this.updateColumnWidths();
10476 handleHdDown : function(e, t){
10477 var hd = e.getTarget('.x-treegrid-hd');
10479 if(hd && Ext.fly(t).hasClass('x-grid3-hd-btn')){
10480 var ms = this.hmenu.items,
10482 index = this.findHeaderIndex(hd),
10487 Ext.fly(hd).addClass('x-grid3-hd-menu-open');
10488 this.hdCtxIndex = index;
10490 this.fireEvent('headerbuttonclick', ms, c, hd, index);
10492 this.hmenu.on('hide', function(){
10493 Ext.fly(hd).removeClass('x-grid3-hd-menu-open');
10494 }, this, {single:true});
10496 this.hmenu.show(t, 'tl-bl?');
10499 var index = this.findHeaderIndex(hd);
10500 this.fireEvent('headerclick', this.columns[index], hd, index);
10505 handleHdOver : function(e, t){
10506 var hd = e.getTarget('.x-treegrid-hd');
10507 if(hd && !this.headersDisabled){
10508 index = this.findHeaderIndex(hd);
10509 this.activeHdRef = t;
10510 this.activeHdIndex = index;
10511 var el = Ext.get(hd);
10512 this.activeHdRegion = el.getRegion();
10513 el.addClass('x-grid3-hd-over');
10514 this.activeHdBtn = el.child('.x-grid3-hd-btn');
10515 if(this.activeHdBtn){
10516 this.activeHdBtn.dom.style.height = (hd.firstChild.offsetHeight-1)+'px';
10522 handleHdOut : function(e, t){
10523 var hd = e.getTarget('.x-treegrid-hd');
10524 if(hd && (!Ext.isIE || !e.within(hd, true))){
10525 this.activeHdRef = null;
10526 Ext.fly(hd).removeClass('x-grid3-hd-over');
10527 hd.style.cursor = '';
10531 findHeaderIndex : function(hd){
10533 var cs = hd.parentNode.childNodes;
10534 for(var i = 0, c; c = cs[i]; i++){
10543 beforeColMenuShow : function(){
10544 var cols = this.columns,
10545 colCount = cols.length,
10547 this.colMenu.removeAll();
10548 for(i = 1; i < colCount; i++){
10550 if(c.hideable !== false){
10551 this.colMenu.add(new Ext.menu.CheckItem({
10552 itemId: 'col-' + i,
10554 checked: !c.hidden,
10556 disabled: c.hideable === false
10563 handleHdMenuClick : function(item){
10564 var index = this.hdCtxIndex,
10565 id = item.getItemId();
10567 if(this.fireEvent('headermenuclick', this.columns[index], id, index) !== false) {
10568 index = id.substr(4);
10569 if(index > 0 && this.columns[index]) {
10570 this.setColumnVisible(index, !item.checked);
10577 setColumnVisible : function(index, visible) {
10578 this.columns[index].hidden = !visible;
10579 this.updateColumnWidths();
10582 <div id="method-Ext.ux.tree.TreeGrid-scrollToTop"></div>/**
10583 * Scrolls the grid to the top
10585 scrollToTop : function(){
10586 this.innerBody.dom.scrollTop = 0;
10587 this.innerBody.dom.scrollLeft = 0;
10591 syncScroll : function(){
10592 this.syncHeaderScroll();
10593 var mb = this.innerBody.dom;
10594 this.fireEvent('bodyscroll', mb.scrollLeft, mb.scrollTop);
10598 syncHeaderScroll : function(){
10599 var mb = this.innerBody.dom;
10600 this.innerHd.dom.scrollLeft = mb.scrollLeft;
10601 this.innerHd.dom.scrollLeft = mb.scrollLeft; // second time for IE (1/2 time first fails, other browsers ignore)
10604 registerNode : function(n) {
10605 Ext.ux.tree.TreeGrid.superclass.registerNode.call(this, n);
10606 if(!n.uiProvider && !n.isRoot && !n.ui.isTreeGridNodeUI) {
10607 n.ui = new Ext.ux.tree.TreeGridNodeUI(n);
10612 Ext.reg('treegrid', Ext.ux.tree.TreeGrid);</pre>