From 1ea34f4332ed8789aa339d63605a3dbaed0b2eb4 Mon Sep 17 00:00:00 2001 From: Renaud Le Gac <renaud.legac@free.fr> Date: Sun, 20 Mar 2011 16:51:42 +0000 Subject: [PATCH] All widget share the same store. Polish the comments here and there. --- static/plugin_dbui/src/appform.js | 8 +++----- static/plugin_dbui/src/appgrid.js | 17 ++++++++++++++++- static/plugin_dbui/src/appgridroweditor.js | 15 ++++----------- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/static/plugin_dbui/src/appform.js b/static/plugin_dbui/src/appform.js index 4a6c396f..a00e2eb7 100644 --- a/static/plugin_dbui/src/appform.js +++ b/static/plugin_dbui/src/appform.js @@ -78,11 +78,9 @@ App.form.FormPanel = Ext.extend(Ext.form.FormPanel, { this.addFieldToolTipsListeners(); // link the form to the data store - if (this.store) { - this.store = Ext.StoreMgr.lookup(this.store); - this.store.on('exception', this.onStoreException, this); - this.store.on('write', resetForm, this.getForm()); - } + this.store = App.getDirectStore(this.store); + this.store.on('exception', this.onStoreException, this); + this.store.on('write', resetForm, this.getForm()); // set the default action: create this.setAction('create'); diff --git a/static/plugin_dbui/src/appgrid.js b/static/plugin_dbui/src/appgrid.js index 6619325d..632f8f0a 100644 --- a/static/plugin_dbui/src/appgrid.js +++ b/static/plugin_dbui/src/appgrid.js @@ -17,7 +17,22 @@ App.grid.Grid = Ext.extend(Ext.grid.GridPanel, { /** * private attributes used by plugins */ - rowEditor: null + rowEditor: null, + + /** + * private method requests by the component model of ExtJS + */ + initComponent: function () { + + // link the grid to the data store + this.store = App.getDirectStore(this.store); + + // initialize the underlying class. DON'T MOVE + App.grid.Grid.superclass.initComponent.call(this); + + this.store.load(); + + } }); Ext.reg('xgrid', App.grid.Grid); diff --git a/static/plugin_dbui/src/appgridroweditor.js b/static/plugin_dbui/src/appgridroweditor.js index b0abc85a..73e6d9c4 100644 --- a/static/plugin_dbui/src/appgridroweditor.js +++ b/static/plugin_dbui/src/appgridroweditor.js @@ -57,13 +57,13 @@ App.grid.RowEditor = Ext.extend(Ext.Window, { // Add a listener to hide the window when the transaction is successful this.grid.store.on('write', this.onWrite, this); - // get the formPanel configuration and instanciate the object + // get the formPanel configuration and instantiate the object table = App.getTableName(this.grid.store); Dbui.getForm(table, this.addFormPanel, this); }, /** - * Private call-back method to instanciate the formPanel + * Private call-back method to instantiate the formPanel * the scope is the gridRowEditor * @param {Object} provider * @param {Object} response @@ -71,15 +71,8 @@ App.grid.RowEditor = Ext.extend(Ext.Window, { addFormPanel: function (provider, response) { var formCfg = response.result; - // By construction the formPanel and the grid share the same store. - // This approach relies on the Ext.StrMgr. - // However this approach creates confusion in listeners. - // It is why we force the use of the same object. - formCfg.store = null; - - // instanciate the form - this.formPanel = Ext.ComponentMgr.create(formCfg); - this.formPanel.store = this.grid.store; + // instantiate the form + this.formPanel = new App.form.FormPanel(formCfg); this.add(this.formPanel); // add a listeners to catch the store exception -- GitLab