PDA

View Full Version : passing additional config props to init



DavidThi808
26 Jul 2013, 12:11 PM
Hi;

I need to set things like a proxy api read uri and a TreeStore root name programatically. I believe the way to do this is by passing in additional config properties. However, I can't figure out how to do this in Architect. Is there something that explains how to do this?

thanks - dave

DavidThi808
15 Aug 2013, 7:56 AM
Help please.

tangix
15 Aug 2013, 10:12 AM
Maybe this old thread can help...
http://www.sencha.com/forum/showthread.php?263665

DavidThi808
15 Aug 2013, 10:58 AM
Hi;

That will work for one case - thank you.

But for the other cases, we have windows that are called on the fly and we only know the url for the datasource at the time we call it. And it will change each time we call. Is there a way to pass in the url?

thanks - dave

tangix
15 Aug 2013, 11:24 AM
OK - tougher one.
In one of my projects I am handling multiple tabs by creating individual stores for each tab (each tab has a grid and a couple of comboboxes) and then setting references to the grid in the tab to that store in the tab instance.
I found out that I needed to be careful not to leak objects and when I close a tab I had to do a manual Ext.destroy() on the store.

/Mattias

DavidThi808
15 Aug 2013, 11:54 AM
Let me ask you a larger question - do you think Architect is worth it with the stuff like this you have to do?

I'm starting to think we should create the initial window layout in Architect, then copy that over to our code base and at that point use WebStorm instead.

??? - thanks - dave

tangix
15 Aug 2013, 9:20 PM
I am not sure I understand your question - having one store per tab is a neccessity imposed by the framework as the filtering from a combobox and grid are applied to one store and can't be shared among instances. This has nothing to do with Architect.

If you ask if I think Architect is worth it unrelated to this issue, my answer will be a simple "yes!".

DavidThi808
16 Aug 2013, 6:51 AM
Hi;

Let me explain better. I have a Window that a user uses to create a select for a database. The window needs to call our REST server to get the metadata for that database and the name of the database is part of the URL for the Store/Model that is the data store for the tree in the Window that displays the metadata.

So, each time this Window is created, it will have a different URL for the tree's data. Every user can have multiple databases and we have many users. So it's not even a set of 20 pre-defined URLs, it's something that does have to be defined each time the Window is instantiated.

In addition, there can be multiple instances of this Window up at once. So each Window needs it's own instantiation of its Store because each will have a different URL.

So I think this means that 1) The Store object must be created inside the Window object so each Window has its own Store object and 2) That we have to set the URL of each Store object when we create it.

Did I miss something or do we need to structure the code as I listed? And if we do, then I think Architect is not usable because it makes the Store a global object and it only allows a literal URL.

??? - thanks - dave

DavidThi808
19 Aug 2013, 1:09 PM
Hi all;

Does anyone have an idea how to do this in Architect?

thanks - dave

aconran
19 Aug 2013, 2:01 PM
David -

At one point (Ext Designer 1.0 days) there was an option on every bindable item that would allow you to instantiate an instance of a store. We do not currently have an option to do that, though we should bring it back. Currently you would have to make a duplicate of the existing store.

DavidThi808
19 Aug 2013, 2:20 PM
Hi;

No problem creating a duplicate if you can point me at how to do that. Do I create another store object, then call Apply() to copy all settings across, then set the url specifically as that will be different?

And when/where do I set this duplicated store as the store for the created window? Can I do that after I instantiate the window? And if so, must I turn autoload off and then explicitly call load? Or can I set it before the autoload triggers?

thanks - dave

DavidThi808
22 Aug 2013, 1:02 PM
Asking again. How can we pass values to a window when we create it using Ext.widget()? The Window is created in Architect.

We need several variables and these are used for multiple things, some for URLs to load data, some for values passing to the business logic.

??? - thanks - dave

tangix
23 Aug 2013, 11:15 AM
I don't know if I understand you question correctly, but if you are asking how to pass additional parameters to a Window you created in SA I'll try to give you an answer. I am not sure what your issues are with SA as this is pure Ext JS stuff, passing config objects to the component when it is instansiated.

I have a base Window created in my project that I'd like to set different titles on. I created the Window in SA and added a process config setting the title to the passed parameter "windowtitle" and load the appropriate help page from the backend using the helpScope parameter.

The complete code for this in SA is:

Ext.define('VPCalcDesktop.view.HelpWindow', {
extend: 'Ext.window.Window',
alias: 'widget.helpwindow',

height: 600,
width: 550,
overflowY: 'auto',
bodyPadding: 15,
title: 'My Window',
modal: true,

initComponent: function() {
var me = this;

Ext.applyIf(me, {
loader: {

},
header: {
titleAlign: 'center'
},
listeners: {
show: {
fn: me.onWindowShow,
scope: me
}
}
});

me.processHelpWindow(me);
me.callParent(arguments);
},

processHelpWindow: function(config) {
config.title = this.windowtitle;
return config;
},

onWindowShow: function(component, eOpts) {
component.getLoader().load({
url: VPCalcDesktop.config.backend + 'help/index/' + this.helpScope + '/se',
loadMask: true,
autoLoad: true
});
}

});

I then call this from my event handlers with the following code:

var w = Ext.create('widget.helpwindow', { helpScope: target.help_tag, windowtitle: VPCalcLang.help_title, animateTarget: target });
w.show();

/Mattias

DavidThi808
23 Aug 2013, 11:45 AM
Hi;

Yes exactly that. However, I want to assign a default value to windowtitle (from your example). Is there a way to do that in Architect?

thanks - dave

tangix
23 Aug 2013, 11:48 PM
See attached archived project created SA 2.2.2.
The property "a_value" is set in the Config panel on the Window using the "Add" button.

DavidThi808
26 Aug 2013, 11:47 AM
hank you