X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775..2e847cf21b8ab9d15fa167b315ca5b2fa92638fc:/pkgs/pkg-grid-foundation-debug.js?ds=sidebyside diff --git a/pkgs/pkg-grid-foundation-debug.js b/pkgs/pkg-grid-foundation-debug.js index 3e09df2b..a53117c0 100644 --- a/pkgs/pkg-grid-foundation-debug.js +++ b/pkgs/pkg-grid-foundation-debug.js @@ -1,6 +1,6 @@ /*! - * Ext JS Library 3.0.3 - * Copyright(c) 2006-2009 Ext JS, LLC + * Ext JS Library 3.1.1 + * Copyright(c) 2006-2010 Ext JS, LLC * licensing@extjs.com * http://www.extjs.com/license */ @@ -217,14 +217,14 @@ Ext.grid.GridPanel = Ext.extend(Ext.Panel, { * @cfg {Array} stateEvents * An array of events that, when fired, should trigger this component to save its state. * Defaults to:
- * stateEvents: ['columnmove', 'columnresize', 'sortchange']
+ * stateEvents: ['columnmove', 'columnresize', 'sortchange', 'groupchange']
*
* These can be any types of events supported by this component, including browser or * custom events (e.g., ['click', 'customerchange']).
*See {@link Ext.Component#stateful} for an explanation of saving and restoring * Component state.
*/ - stateEvents : ['columnmove', 'columnresize', 'sortchange'], + stateEvents : ['columnmove', 'columnresize', 'sortchange', 'groupchange'], /** * @cfg {Object} view The {@link Ext.grid.GridView} used by the grid. This can be set * before a call to {@link Ext.Component#render render()}. @@ -234,6 +234,7 @@ Ext.grid.GridPanel = Ext.extend(Ext.Panel, { /** * @cfg {Array} bubbleEvents *An array of events that, when fired, should be bubbled to any parent container.
+ * See {@link Ext.util.Observable#enableBubble}.
* Defaults to [].
*/
bubbleEvents: [],
@@ -364,6 +365,33 @@ Ext.grid.GridPanel = Ext.extend(Ext.Panel, {
* @param {Ext.EventObject} e
*/
'headermousedown',
+
+ /**
+ * @event groupmousedown
+ * Fires before a group header is clicked. Only applies for grids with a {@link Ext.grid.GroupingView GroupingView}.
+ * @param {Grid} this
+ * @param {String} groupField
+ * @param {String} groupValue
+ * @param {Ext.EventObject} e
+ */
+ 'groupmousedown',
+
+ /**
+ * @event rowbodymousedown
+ * Fires before the row body is clicked. Only applies for grids with {@link Ext.grid.GridView#enableRowBody enableRowBody} configured.
+ * @param {Grid} this
+ * @param {Number} rowIndex
+ * @param {Ext.EventObject} e
+ */
+ 'rowbodymousedown',
+
+ /**
+ * @event containermousedown
+ * Fires before the container is clicked. The container consists of any part of the grid body that is not covered by a row.
+ * @param {Grid} this
+ * @param {Ext.EventObject} e
+ */
+ 'containermousedown',
/**
* @event cellclick
@@ -425,6 +453,56 @@ function(grid, rowIndex, columnIndex, e) {
* @param {Ext.EventObject} e
*/
'headerdblclick',
+ /**
+ * @event groupclick
+ * Fires when group header is clicked. Only applies for grids with a {@link Ext.grid.GroupingView GroupingView}.
+ * @param {Grid} this
+ * @param {String} groupField
+ * @param {String} groupValue
+ * @param {Ext.EventObject} e
+ */
+ 'groupclick',
+ /**
+ * @event groupdblclick
+ * Fires when group header is double clicked. Only applies for grids with a {@link Ext.grid.GroupingView GroupingView}.
+ * @param {Grid} this
+ * @param {String} groupField
+ * @param {String} groupValue
+ * @param {Ext.EventObject} e
+ */
+ 'groupdblclick',
+ /**
+ * @event containerclick
+ * Fires when the container is clicked. The container consists of any part of the grid body that is not covered by a row.
+ * @param {Grid} this
+ * @param {Ext.EventObject} e
+ */
+ 'containerclick',
+ /**
+ * @event containerdblclick
+ * Fires when the container is double clicked. The container consists of any part of the grid body that is not covered by a row.
+ * @param {Grid} this
+ * @param {Ext.EventObject} e
+ */
+ 'containerdblclick',
+
+ /**
+ * @event rowbodyclick
+ * Fires when the row body is clicked. Only applies for grids with {@link Ext.grid.GridView#enableRowBody enableRowBody} configured.
+ * @param {Grid} this
+ * @param {Number} rowIndex
+ * @param {Ext.EventObject} e
+ */
+ 'rowbodyclick',
+ /**
+ * @event rowbodydblclick
+ * Fires when the row body is double clicked. Only applies for grids with {@link Ext.grid.GridView#enableRowBody enableRowBody} configured.
+ * @param {Grid} this
+ * @param {Number} rowIndex
+ * @param {Ext.EventObject} e
+ */
+ 'rowbodydblclick',
+
/**
* @event rowcontextmenu
* Fires when a row is right clicked
@@ -450,6 +528,30 @@ function(grid, rowIndex, columnIndex, e) {
* @param {Ext.EventObject} e
*/
'headercontextmenu',
+ /**
+ * @event groupcontextmenu
+ * Fires when group header is right clicked. Only applies for grids with a {@link Ext.grid.GroupingView GroupingView}.
+ * @param {Grid} this
+ * @param {String} groupField
+ * @param {String} groupValue
+ * @param {Ext.EventObject} e
+ */
+ 'groupcontextmenu',
+ /**
+ * @event containercontextmenu
+ * Fires when the container is right clicked. The container consists of any part of the grid body that is not covered by a row.
+ * @param {Grid} this
+ * @param {Ext.EventObject} e
+ */
+ 'containercontextmenu',
+ /**
+ * @event rowbodycontextmenu
+ * Fires when the row body is right clicked. Only applies for grids with {@link Ext.grid.GridView#enableRowBody enableRowBody} configured.
+ * @param {Grid} this
+ * @param {Number} rowIndex
+ * @param {Ext.EventObject} e
+ */
+ 'rowbodycontextmenu',
/**
* @event bodyscroll
* Fires when the body element is scrolled
@@ -478,6 +580,13 @@ function(grid, rowIndex, columnIndex, e) {
* @param {Object} sortInfo An object with the keys field and direction
*/
'sortchange',
+ /**
+ * @event groupchange
+ * Fires when the grid's grouping changes (only applies for grids with a {@link Ext.grid.GroupingView GroupingView})
+ * @param {Grid} this
+ * @param {String} groupField A string with the grouping field, null if the store is not grouped.
+ */
+ 'groupchange',
/**
* @event reconfigure
* Fires when the grid is reconfigured with a new store and/or column model.
@@ -485,7 +594,13 @@ function(grid, rowIndex, columnIndex, e) {
* @param {Ext.data.Store} store The new store
* @param {Ext.grid.ColumnModel} colModel The new column model
*/
- 'reconfigure'
+ 'reconfigure',
+ /**
+ * @event viewready
+ * Fires when the grid view is available (use this for selecting a default row).
+ * @param {Grid} this
+ */
+ 'viewready'
);
},
@@ -530,23 +645,40 @@ function(grid, rowIndex, columnIndex, e) {
applyState : function(state){
var cm = this.colModel,
- cs = state.columns;
+ cs = state.columns,
+ store = this.store,
+ s,
+ c,
+ oldIndex;
+
if(cs){
for(var i = 0, len = cs.length; i < len; i++){
- var s = cs[i];
- var c = cm.getColumnById(s.id);
+ s = cs[i];
+ c = cm.getColumnById(s.id);
if(c){
c.hidden = s.hidden;
c.width = s.width;
- var oldIndex = cm.getIndexById(s.id);
+ oldIndex = cm.getIndexById(s.id);
if(oldIndex != i){
cm.moveColumn(oldIndex, i);
}
}
}
}
- if(state.sort && this.store){
- this.store[this.store.remoteSort ? 'setDefaultSort' : 'sort'](state.sort.field, state.sort.direction);
+ if(store){
+ s = state.sort;
+ if(s){
+ store[store.remoteSort ? 'setDefaultSort' : 'sort'](s.field, s.direction);
+ }
+ s = state.group;
+ if(store.groupBy){
+ if(s){
+ store.groupBy(s);
+ }else{
+ store.clearGrouping();
+ }
+ }
+
}
var o = Ext.apply({}, state);
delete o.columns;
@@ -555,7 +687,11 @@ function(grid, rowIndex, columnIndex, e) {
},
getState : function(){
- var o = {columns: []};
+ var o = {columns: []},
+ store = this.store,
+ ss,
+ gs;
+
for(var i = 0, c; (c = this.colModel.config[i]); i++){
o.columns[i] = {
id: c.id,
@@ -565,11 +701,17 @@ function(grid, rowIndex, columnIndex, e) {
o.columns[i].hidden = true;
}
}
- if(this.store){
- var ss = this.store.getSortState();
+ if(store){
+ ss = store.getSortState();
if(ss){
o.sort = ss;
}
+ if(store.getGroupState){
+ gs = store.getGroupState();
+ if(gs){
+ o.group = gs;
+ }
+ }
}
return o;
},
@@ -601,15 +743,20 @@ function(grid, rowIndex, columnIndex, e) {
* @param {Ext.grid.ColumnModel} colModel The new {@link Ext.grid.ColumnModel} object
*/
reconfigure : function(store, colModel){
- if(this.loadMask){
- this.loadMask.destroy();
- this.loadMask = new Ext.LoadMask(this.bwrap,
- Ext.apply({}, {store:store}, this.initialConfig.loadMask));
+ var rendered = this.rendered;
+ if(rendered){
+ if(this.loadMask){
+ this.loadMask.destroy();
+ this.loadMask = new Ext.LoadMask(this.bwrap,
+ Ext.apply({}, {store:store}, this.initialConfig.loadMask));
+ }
+ }
+ if(this.view){
+ this.view.initData(store, colModel);
}
- this.view.initData(store, colModel);
this.store = store;
this.colModel = colModel;
- if(this.rendered){
+ if(rendered){
this.view.refresh(true);
}
this.fireEvent('reconfigure', this, store, colModel);
@@ -618,9 +765,6 @@ function(grid, rowIndex, columnIndex, e) {
// private
onDestroy : function(){
if(this.rendered){
- var c = this.body;
- c.removeAllListeners();
- c.update('');
Ext.destroy(this.view, this.loadMask);
}else if(this.store && this.store.autoDestroy){
this.store.destroy();
@@ -633,21 +777,31 @@ function(grid, rowIndex, columnIndex, e) {
// private
processEvent : function(name, e){
this.fireEvent(name, e);
- var t = e.getTarget();
- var v = this.view;
- var header = v.findHeaderIndex(t);
+ var t = e.getTarget(),
+ v = this.view,
+ header = v.findHeaderIndex(t);
+
if(header !== false){
this.fireEvent('header' + name, this, header, e);
}else{
- var row = v.findRowIndex(t);
- var cell = v.findCellIndex(t);
+ var row = v.findRowIndex(t),
+ cell,
+ body;
if(row !== false){
this.fireEvent('row' + name, this, row, e);
+ cell = v.findCellIndex(t);
+ body = v.findRowBody(t);
if(cell !== false){
this.fireEvent('cell' + name, this, row, cell, e);
}
+ if(body){
+ this.fireEvent('rowbody' + name, this, row, e);
+ }
+ }else{
+ this.fireEvent('container' + name, this, e);
}
}
+ this.view.processEvent(name, e);
},
// private
@@ -672,8 +826,11 @@ function(grid, rowIndex, columnIndex, e) {
// private
walkCells : function(row, col, step, fn, scope){
- var cm = this.colModel, clen = cm.getColumnCount();
- var ds = this.store, rlen = ds.getCount(), first = true;
+ var cm = this.colModel,
+ clen = cm.getColumnCount(),
+ ds = this.store,
+ rlen = ds.getCount(),
+ first = true;
if(step < 0){
if(col < 0){
row--;
@@ -891,7 +1048,7 @@ function(grid, rowIndex, columnIndex, e) {
* @hide
*/
/**
- * @event afterLayout
+ * @event afterlayout
* @hide
*/
/**
@@ -975,67 +1132,7 @@ Ext.reg('grid', Ext.grid.GridPanel);/**
* @constructor
* @param {Object} config
*/
-Ext.grid.GridView = function(config){
- Ext.apply(this, config);
- // These events are only used internally by the grid components
- this.addEvents(
- /**
- * @event beforerowremoved
- * Internal UI Event. Fired before a row is removed.
- * @param {Ext.grid.GridView} view
- * @param {Number} rowIndex The index of the row to be removed.
- * @param {Ext.data.Record} record The Record to be removed
- */
- 'beforerowremoved',
- /**
- * @event beforerowsinserted
- * Internal UI Event. Fired before rows are inserted.
- * @param {Ext.grid.GridView} view
- * @param {Number} firstRow The index of the first row to be inserted.
- * @param {Number} lastRow The index of the last row to be inserted.
- */
- 'beforerowsinserted',
- /**
- * @event beforerefresh
- * Internal UI Event. Fired before the view is refreshed.
- * @param {Ext.grid.GridView} view
- */
- 'beforerefresh',
- /**
- * @event rowremoved
- * Internal UI Event. Fired after a row is removed.
- * @param {Ext.grid.GridView} view
- * @param {Number} rowIndex The index of the row that was removed.
- * @param {Ext.data.Record} record The Record that was removed
- */
- 'rowremoved',
- /**
- * @event rowsinserted
- * Internal UI Event. Fired after rows are inserted.
- * @param {Ext.grid.GridView} view
- * @param {Number} firstRow The index of the first inserted.
- * @param {Number} lastRow The index of the last row inserted.
- */
- 'rowsinserted',
- /**
- * @event rowupdated
- * Internal UI Event. Fired after a row has been updated.
- * @param {Ext.grid.GridView} view
- * @param {Number} firstRow The index of the row updated.
- * @param {Ext.data.record} record The Record backing the row updated.
- */
- 'rowupdated',
- /**
- * @event refresh
- * Internal UI Event. Fired after the GridView's body has been refreshed.
- * @param {Ext.grid.GridView} view
- */
- 'refresh'
- );
- Ext.grid.GridView.superclass.constructor.call(this);
-};
-
-Ext.extend(Ext.grid.GridView, Ext.util.Observable, {
+Ext.grid.GridView = Ext.extend(Ext.util.Observable, {
/**
* Override this function to apply custom CSS classes to rows during rendering. You can also supply custom
* parameters to the row template for the current row to customize how it is rendered using the rowParams
@@ -1184,6 +1281,11 @@ viewConfig: {
* @cfg {Number} rowSelectorDepth The number of levels to search for rows in event delegation (defaults to 10)
*/
rowSelectorDepth : 10,
+
+ /**
+ * @cfg {Number} rowBodySelectorDepth The number of levels to search for row bodies in event delegation (defaults to 10)
+ */
+ rowBodySelectorDepth : 10,
/**
* @cfg {String} cellSelector The selector used to find cells internally (defaults to 'td.x-grid3-cell')
@@ -1194,10 +1296,75 @@ viewConfig: {
*/
rowSelector : 'div.x-grid3-row',
+ /**
+ * @cfg {String} rowBodySelector The selector used to find row bodies internally (defaults to 'div.x-grid3-row')
+ */
+ rowBodySelector : 'div.x-grid3-row-body',
+
// private
firstRowCls: 'x-grid3-row-first',
lastRowCls: 'x-grid3-row-last',
rowClsRe: /(?:^|\s+)x-grid3-row-(first|last|alt)(?:\s+|$)/g,
+
+ constructor : function(config){
+ Ext.apply(this, config);
+ // These events are only used internally by the grid components
+ this.addEvents(
+ /**
+ * @event beforerowremoved
+ * Internal UI Event. Fired before a row is removed.
+ * @param {Ext.grid.GridView} view
+ * @param {Number} rowIndex The index of the row to be removed.
+ * @param {Ext.data.Record} record The Record to be removed
+ */
+ 'beforerowremoved',
+ /**
+ * @event beforerowsinserted
+ * Internal UI Event. Fired before rows are inserted.
+ * @param {Ext.grid.GridView} view
+ * @param {Number} firstRow The index of the first row to be inserted.
+ * @param {Number} lastRow The index of the last row to be inserted.
+ */
+ 'beforerowsinserted',
+ /**
+ * @event beforerefresh
+ * Internal UI Event. Fired before the view is refreshed.
+ * @param {Ext.grid.GridView} view
+ */
+ 'beforerefresh',
+ /**
+ * @event rowremoved
+ * Internal UI Event. Fired after a row is removed.
+ * @param {Ext.grid.GridView} view
+ * @param {Number} rowIndex The index of the row that was removed.
+ * @param {Ext.data.Record} record The Record that was removed
+ */
+ 'rowremoved',
+ /**
+ * @event rowsinserted
+ * Internal UI Event. Fired after rows are inserted.
+ * @param {Ext.grid.GridView} view
+ * @param {Number} firstRow The index of the first inserted.
+ * @param {Number} lastRow The index of the last row inserted.
+ */
+ 'rowsinserted',
+ /**
+ * @event rowupdated
+ * Internal UI Event. Fired after a row has been updated.
+ * @param {Ext.grid.GridView} view
+ * @param {Number} firstRow The index of the row updated.
+ * @param {Ext.data.record} record The Record backing the row updated.
+ */
+ 'rowupdated',
+ /**
+ * @event refresh
+ * Internal UI Event. Fired after the GridView's body has been refreshed.
+ * @param {Ext.grid.GridView} view
+ */
+ 'refresh'
+ );
+ Ext.grid.GridView.superclass.constructor.call(this);
+ },
/* -------------------------------- UI Specific ----------------------------- */
@@ -1256,7 +1423,7 @@ viewConfig: {
for(var k in ts){
var t = ts[k];
- if(t && typeof t.compile == 'function' && !t.compiled){
+ if(t && Ext.isFunction(t.compile) && !t.compiled){
t.disableFormats = true;
t.compile();
}
@@ -1389,6 +1556,18 @@ viewConfig: {
var r = this.findRow(el);
return r ? r.rowIndex : false;
},
+
+ /**
+ * Return the HtmlElement representing the grid row body which contains the passed element.
+ * @param {HTMLElement} el The target HTMLElement
+ * @return {HTMLElement} The row body element, or null if the target element is not within a row body of this GridView.
+ */
+ findRowBody : function(el){
+ if(!el){
+ return false;
+ }
+ return this.fly(el).findParent(this.rowBodySelector, this.rowBodySelectorDepth);
+ },
// getter methods for fetching elements dynamically in the grid
@@ -1594,12 +1773,12 @@ viewConfig: {
p.id = c.id;
p.css = i === 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
p.attr = p.cellAttr = '';
- p.value = c.renderer(r.data[c.name], p, r, rowIndex, i, ds);
+ p.value = c.renderer.call(c.scope, r.data[c.name], p, r, rowIndex, i, ds);
p.style = c.style;
if(Ext.isEmpty(p.value)){
p.value = ' ';
}
- if(this.markDirty && r.dirty && typeof r.modified[c.name] !== 'undefined'){
+ if(this.markDirty && r.dirty && Ext.isDefined(r.modified[c.name])){
p.css += ' x-grid3-dirty-cell';
}
cb[cb.length] = ct.apply(p);
@@ -1627,18 +1806,24 @@ viewConfig: {
if(!this.ds || this.ds.getCount() < 1){
return;
}
- var rows = this.getRows();
+ var rows = this.getRows(),
+ len = rows.length,
+ i, r;
+
skipStripe = skipStripe || !this.grid.stripeRows;
startRow = startRow || 0;
- Ext.each(rows, function(row, idx){
- row.rowIndex = idx;
- if(!skipStripe){
- row.className = row.className.replace(this.rowClsRe, ' ');
- if ((idx + 1) % 2 === 0){
- row.className += ' x-grid3-row-alt';
- }
- }
- }, this);
+ for(i = 0; i While subclasses are provided to render data in different ways, this class renders a passed
* data field unchanged and is usually used for textual columns.{@link #setColumnWidth}
.
- * Note internal resizing suppresses the event from firing. See also
- * {@link Ext.grid.GridPanel}.{@link #columnresize}
.
- * @param {ColumnModel} this
- * @param {Number} columnIndex The column index
- * @param {Number} newWidth The new width
- */
- "widthchange",
- /**
- * @event headerchange
- * Fires when the text of a header changes.
- * @param {ColumnModel} this
- * @param {Number} columnIndex The column index
- * @param {String} newText The new header text
- */
- "headerchange",
- /**
- * @event hiddenchange
- * Fires when a column is hidden or "unhidden".
- * @param {ColumnModel} this
- * @param {Number} columnIndex The column index
- * @param {Boolean} hidden true if hidden, false otherwise
- */
- "hiddenchange",
- /**
- * @event columnmoved
- * Fires when a column is moved.
- * @param {ColumnModel} this
- * @param {Number} oldIndex
- * @param {Number} newIndex
- */
- "columnmoved",
- /**
- * @event configchange
- * Fires when the configuration is changed
- * @param {ColumnModel} this
- */
- "configchange"
- );
- Ext.grid.ColumnModel.superclass.constructor.call(this);
-};
-Ext.extend(Ext.grid.ColumnModel, Ext.util.Observable, {
+Ext.grid.ColumnModel = Ext.extend(Ext.util.Observable, {
/**
* @cfg {Number} defaultWidth (optional) The width of columns which have no {@link #width}
* specified (defaults to 100). This property shall preferably be configured through the
@@ -3281,6 +3432,66 @@ Ext.extend(Ext.grid.ColumnModel, Ext.util.Observable, {
* configuration options to all {@link #columns}. Configuration options specified with
* individual {@link Ext.grid.Column column} configs will supersede these {@link #defaults}.
*/
+
+ constructor : function(config){
+ /**
+ * An Array of {@link Ext.grid.Column Column definition} objects representing the configuration
+ * of this ColumnModel. See {@link Ext.grid.Column} for the configuration properties that may
+ * be specified.
+ * @property config
+ * @type Array
+ */
+ if(config.columns){
+ Ext.apply(this, config);
+ this.setConfig(config.columns, true);
+ }else{
+ this.setConfig(config, true);
+ }
+ this.addEvents(
+ /**
+ * @event widthchange
+ * Fires when the width of a column is programmaticially changed using
+ * {@link #setColumnWidth}
.
+ * Note internal resizing suppresses the event from firing. See also
+ * {@link Ext.grid.GridPanel}.{@link #columnresize}
.
+ * @param {ColumnModel} this
+ * @param {Number} columnIndex The column index
+ * @param {Number} newWidth The new width
+ */
+ "widthchange",
+ /**
+ * @event headerchange
+ * Fires when the text of a header changes.
+ * @param {ColumnModel} this
+ * @param {Number} columnIndex The column index
+ * @param {String} newText The new header text
+ */
+ "headerchange",
+ /**
+ * @event hiddenchange
+ * Fires when a column is hidden or "unhidden".
+ * @param {ColumnModel} this
+ * @param {Number} columnIndex The column index
+ * @param {Boolean} hidden true if hidden, false otherwise
+ */
+ "hiddenchange",
+ /**
+ * @event columnmoved
+ * Fires when a column is moved.
+ * @param {ColumnModel} this
+ * @param {Number} oldIndex
+ * @param {Number} newIndex
+ */
+ "columnmoved",
+ /**
+ * @event configchange
+ * Fires when the configuration is changed
+ * @param {ColumnModel} this
+ */
+ "configchange"
+ );
+ Ext.grid.ColumnModel.superclass.constructor.call(this);
+ },
/**
* Returns the id of the column at the specified index.
@@ -3310,10 +3521,7 @@ Ext.extend(Ext.grid.ColumnModel, Ext.util.Observable, {
if(!initial){ // cleanup
delete this.totalWidth;
for(i = 0, len = this.config.length; i < len; i++){
- c = this.config[i];
- if(c.editor){
- c.editor.destroy();
- }
+ this.config[i].destroy();
}
}
@@ -3329,7 +3537,7 @@ Ext.extend(Ext.grid.ColumnModel, Ext.util.Observable, {
for(i = 0, len = config.length; i < len; i++){
c = Ext.applyIf(config[i], this.defaults);
// if no id, create one using column's ordinal position
- if(typeof c.id == 'undefined'){
+ if(Ext.isEmpty(c.id)){
c.id = i;
}
if(!c.isColumn){
@@ -3407,8 +3615,10 @@ var columns = grid.getColumnModel().getColumnsBy(function(c){
return c.hidden;
});
- * @param {Function} fn
- * @param {Object} scope (optional)
+ * @param {Function} fn A function which, when passed a {@link Ext.grid.Column Column} object, must
+ * return true
if the column is to be included in the returned Array.
+ * @param {Object} scope (optional) The scope (this
reference) in which the function
+ * is executed. Defaults to this ColumnModel.
* @return {Array} result
*/
getColumnsBy : function(fn, scope){
@@ -3451,6 +3661,10 @@ var columns = grid.getColumnModel().getColumnsBy(function(c){
}
return this.config[col].renderer;
},
+
+ getRendererScope : function(col){
+ return this.config[col].scope;
+ },
/**
* Sets the rendering (formatting) function for a column. See {@link Ext.util.Format} for some
@@ -3612,7 +3826,11 @@ var grid = new Ext.grid.GridPanel({
* @return {Boolean}
*/
isCellEditable : function(colIndex, rowIndex){
- return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
+ var c = this.config[colIndex],
+ ed = c.editable;
+
+ //force boolean
+ return !!(ed || (!Ext.isDefined(ed) && c.editor));
},
/**
@@ -3685,16 +3903,15 @@ myGrid.getColumnModel().setHidden(0, true); // hide column 0 (0 = the first colu
* @param {Object} editor The editor object
*/
setEditor : function(col, editor){
- Ext.destroy(this.config[col].editor);
- this.config[col].editor = editor;
+ this.config[col].setEditor(editor);
},
/**
* Destroys this column model by purging any event listeners, and removing any editors.
*/
destroy : function(){
- for(var i = 0, c = this.config, len = c.length; i < len; i++){
- Ext.destroy(c[i].editor);
+ for(var i = 0, len = this.config.length; i < len; i++){
+ this.config[i].destroy();
}
this.purgeListeners();
}
@@ -3713,17 +3930,17 @@ Ext.grid.ColumnModel.defaultRenderer = function(value){
* implemented by descendant classes. This class should not be directly instantiated.
* @constructor
*/
-Ext.grid.AbstractSelectionModel = function(){
- this.locked = false;
- Ext.grid.AbstractSelectionModel.superclass.constructor.call(this);
-};
-
-Ext.extend(Ext.grid.AbstractSelectionModel, Ext.util.Observable, {
+Ext.grid.AbstractSelectionModel = Ext.extend(Ext.util.Observable, {
/**
* The GridPanel for which this SelectionModel is handling selection. Read-only.
* @type Object
* @property grid
*/
+
+ constructor : function(){
+ this.locked = false;
+ Ext.grid.AbstractSelectionModel.superclass.constructor.call(this);
+ },
/** @ignore Called by the grid automatically. Do not call directly. */
init : function(grid){
@@ -3766,60 +3983,59 @@ Ext.extend(Ext.grid.AbstractSelectionModel, Ext.util.Observable, {
* @constructor
* @param {Object} config
*/
-Ext.grid.RowSelectionModel = function(config){
- Ext.apply(this, config);
- this.selections = new Ext.util.MixedCollection(false, function(o){
- return o.id;
- });
-
- this.last = false;
- this.lastActive = false;
-
- this.addEvents(
- /**
- * @event selectionchange
- * Fires when the selection changes
- * @param {SelectionModel} this
- */
- 'selectionchange',
- /**
- * @event beforerowselect
- * Fires before a row is selected, return false to cancel the selection.
- * @param {SelectionModel} this
- * @param {Number} rowIndex The index to be selected
- * @param {Boolean} keepExisting False if other selections will be cleared
- * @param {Record} record The record to be selected
- */
- 'beforerowselect',
- /**
- * @event rowselect
- * Fires when a row is selected.
- * @param {SelectionModel} this
- * @param {Number} rowIndex The selected index
- * @param {Ext.data.Record} r The selected record
- */
- 'rowselect',
- /**
- * @event rowdeselect
- * Fires when a row is deselected. To prevent deselection
- * {@link Ext.grid.AbstractSelectionModel#lock lock the selections}.
- * @param {SelectionModel} this
- * @param {Number} rowIndex
- * @param {Record} record
- */
- 'rowdeselect'
- );
-
- Ext.grid.RowSelectionModel.superclass.constructor.call(this);
-};
-
-Ext.extend(Ext.grid.RowSelectionModel, Ext.grid.AbstractSelectionModel, {
+Ext.grid.RowSelectionModel = Ext.extend(Ext.grid.AbstractSelectionModel, {
/**
* @cfg {Boolean} singleSelect
* true to allow selection of only one row at a time (defaults to false
* allowing multiple selections)
*/
singleSelect : false,
+
+ constructor : function(config){
+ Ext.apply(this, config);
+ this.selections = new Ext.util.MixedCollection(false, function(o){
+ return o.id;
+ });
+
+ this.last = false;
+ this.lastActive = false;
+
+ this.addEvents(
+ /**
+ * @event selectionchange
+ * Fires when the selection changes
+ * @param {SelectionModel} this
+ */
+ 'selectionchange',
+ /**
+ * @event beforerowselect
+ * Fires before a row is selected, return false to cancel the selection.
+ * @param {SelectionModel} this
+ * @param {Number} rowIndex The index to be selected
+ * @param {Boolean} keepExisting False if other selections will be cleared
+ * @param {Record} record The record to be selected
+ */
+ 'beforerowselect',
+ /**
+ * @event rowselect
+ * Fires when a row is selected.
+ * @param {SelectionModel} this
+ * @param {Number} rowIndex The selected index
+ * @param {Ext.data.Record} r The selected record
+ */
+ 'rowselect',
+ /**
+ * @event rowdeselect
+ * Fires when a row is deselected. To prevent deselection
+ * {@link Ext.grid.AbstractSelectionModel#lock lock the selections}.
+ * @param {SelectionModel} this
+ * @param {Number} rowIndex
+ * @param {Record} record
+ */
+ 'rowdeselect'
+ );
+ Ext.grid.RowSelectionModel.superclass.constructor.call(this);
+ },
/**
* @cfg {Boolean} moveEditorOnEnter
@@ -4006,8 +4222,8 @@ Ext.extend(Ext.grid.RowSelectionModel, Ext.grid.AbstractSelectionModel, {
* Calls the passed function with each selection. If the function returns
* false, iteration is stopped and this function returns
* false. Otherwise it returns true.
- * @param {Function} fn
- * @param {Object} scope (optional)
+ * @param {Function} fn The function to call upon each iteration. It is passed the selected {@link Ext.data.Record Record}.
+ * @param {Object} scope (optional) The scope (this
reference) in which the function is executed. Defaults to this RowSelectionModel.
* @return {Boolean} true if all selections were iterated
*/
each : function(fn, scope){
@@ -4296,23 +4512,7 @@ Ext.extend(Ext.grid.RowSelectionModel, Ext.grid.AbstractSelectionModel, {
*