Skip to content

Commit

Permalink
Fixed tab panel render strategy bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed Spencer committed Sep 17, 2009
1 parent f467653 commit fa54dda
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 17 deletions.
14 changes: 11 additions & 3 deletions controller/Controller.js
Expand Up @@ -253,9 +253,17 @@ ExtMVC.registerController('controller', {
* The tabpanel render strategy
*/
tabPanelRenderStrategy: function(container, view) {
container.add(view);
container.doLayout();
container.activate(view);
var existing = container.getItem(view.id);

//don't add a tab with the same id as an existing one
if (existing == undefined) {
container.add(view);
container.doLayout();
container.activate(view);
} else {
container.setActiveTab(view.id);
view.destroy();
}
},

/**
Expand Down
2 changes: 1 addition & 1 deletion ext-mvc-all-min.js

Large diffs are not rendered by default.

33 changes: 25 additions & 8 deletions ext-mvc-all.js
Expand Up @@ -2827,9 +2827,17 @@ ExtMVC.registerController('controller', {
* The tabpanel render strategy
*/
tabPanelRenderStrategy: function(container, view) {
container.add(view);
container.doLayout();
container.activate(view);
var existing = container.getItem(view.id);

//don't add a tab with the same id as an existing one
if (existing == undefined) {
container.add(view);
container.doLayout();
container.activate(view);
} else {
container.setActiveTab(view.id);
view.destroy();
}
},

/**
Expand Down Expand Up @@ -5721,7 +5729,14 @@ ExtMVC.registerView('scaffold', 'index', {
viewConfig: { forceFit: true },
id: String.format("{0}_index", this.model.prototype.tableName),

loadMask: true
loadMask: true,

/**
* @property dblClickToEdit
* @type Boolean
* True to edit a record when it is double clicked (defaults to true)
*/
dblClickToEdit: true
});

Ext.grid.GridPanel.prototype.constructor.call(this, config);
Expand Down Expand Up @@ -5794,10 +5809,12 @@ ExtMVC.registerView('scaffold', 'index', {
* Mostly, this is simply a case of capturing events received and re-emitting normalized events
*/
initListeners: function() {
this.on({
scope : this,
'dblclick': this.onEdit
});
if (this.dblClickToEdit === true) {
this.on({
scope : this,
'rowdblclick': this.onEdit
});
}

if (this.controller != undefined) {
this.controller.on('delete', this.refreshStore, this);
Expand Down
19 changes: 14 additions & 5 deletions view/scaffold/Index.js
Expand Up @@ -27,7 +27,14 @@ ExtMVC.registerView('scaffold', 'index', {
viewConfig: { forceFit: true },
id: String.format("{0}_index", this.model.prototype.tableName),

loadMask: true
loadMask: true,

/**
* @property dblClickToEdit
* @type Boolean
* True to edit a record when it is double clicked (defaults to true)
*/
dblClickToEdit: true
});

Ext.grid.GridPanel.prototype.constructor.call(this, config);
Expand Down Expand Up @@ -100,10 +107,12 @@ ExtMVC.registerView('scaffold', 'index', {
* Mostly, this is simply a case of capturing events received and re-emitting normalized events
*/
initListeners: function() {
this.on({
scope : this,
'dblclick': this.onEdit
});
if (this.dblClickToEdit === true) {
this.on({
scope : this,
'rowdblclick': this.onEdit
});
}

if (this.controller != undefined) {
this.controller.on('delete', this.refreshStore, this);
Expand Down

0 comments on commit fa54dda

Please sign in to comment.