Currently a Ext JS 4 uses getNameByAlias of https://docs.sencha.com/extjs/4.2.6/#!/api/Ext.ClassManager in its code to map database dynamic alias configurations to class matching to it.
Application needs to upgrade Ext JS. In Ext JS 5 method was removed. Having an extjs alias, is there a dynamic way by code to determine the matching implementation class?
Ext.define('classNameIneed',
extends: ...,
alias: 'aliasIhave',
....
You can still use Ext.ClassManager.getNameByAlias in ExtJs5.
Its definition got moved to Ext.Inventory.
Not pretty but should do the trick.
Ext.getclassName(Ext.createByAlias('aliasIhave')}
Related
I have a requirement that I want to add namespaces in requires conditionally.
e.g. In below example I want to add 'views.popupgrid' name space on specific condition. Currently it's always loaded.
requires: ['Ext.window.MessageBox','views.popupgrid','user.MyUser' ]
Conditional dependencies are not supported by the Sencha toolchain. While you would be able to write in a text editor of your choice
requires:[
(location.hash=='#test')?'testpopup':'normalpopup'
]
and this would work in the uncompiled version, Sencha Cmd would not be able to compile it correctly, and would throw errors.
Therefore, Sencha Architect does not support this syntax.
What you can do, while staying Standards-compliant: you can use Ext.Loader.loadScript, e.g. like this:
Ext.define('MyForm',{
extend: 'Ext.form.Panel'
initComponent:function() {
var me = this;
me.callParent(arguments);
if(x==3) Ext.Loader.loadScript({
url:'MyCustomFormComponent.js',
onLoad:function(){
me.add({
xtype:'mycustomformcomponent'
});
})
});
}
})
Please note that in this case you will always have to deliver MyCustomFormComponent.js alongside the minified app.js, because the dependency cannot be resolved by the toolchain. Also, depending on the connection, there may be a visible delay before the resource is loaded and the component is added to the form.
It is usually faster and smoother to always load the dependency, especially if you intend to deliver the app as a single minified javascript file (e.g. using Sencha Cmd).
I'm trying to apply Marionette into our architecture as it seems to fit our current application better than other solutions. Our frontend HTML is mostly server-side generated using PHP and Twig (just to give some context).
I'm now trying to use Marionette 3 Regions to achieve View compositions in a context where header, footer and generally the main content HTML are already there in the page.
I couldn't find any example with this approach so I'm asking here if someone could give some advice.
Thanks!
You can easily attach views to existing DOM elements using marionette:
var MyView = Mn.View({
el: '#base-element',
template: false
});
Also reference: http://marionettejs.com/docs/master/marionette.view.html
According to http://book.cakephp.org/3.0/en/views/helpers/form.html#customizing-the-templates-formhelper-uses,
the way to point to a list of template containers, is to create a file inside config folder.
// In a View class
$this->loadHelper('Form', [
'templates' => 'app_form',
]);
This would load the tags in config/app_form.php. This file should
contain an array of templates indexed by name:
How do I do the same by pointing at a file inside a Plugin instead?
How do I do the same by pointing at a file inside a Plugin instead?
Guess as everywhere else in the framework? Dot notation: PluginName.app_form
If that is not working it should be added to the framework to be consistent.
I am trying to test my code in angular-ui-grid using this tutorial in the Jasmine testing framework, but I struggle in doing that. According to the tutorial you shuld require the file gridTestUtil.scenario.js and then you can use existing scenarios, but I can't make it work.
I tried doing that, as the tutorial says:
var gridTestUtils = require( './gridTestUtils.scenario.js');
gridTestUtils.expectRowCount( 'myGrid', 3 );
Is there anyone who could show me how to use their testing scenarios (such as expectRowCount, expectCellValueMatch, ect.) or to add a code sample.
Thanks :)
The file gridTestUtils.scenario.js has been changed to gridTestUtils.spec.js so plz copy the new file in the same folder as as your spec file and try
var gridTestUtils = require( './gridTestUtils.spec.js');
gridTestUtils.expectRowCount( 'myGrid', 3 );
to get the row count.
Use This link as reference to cover all the available testing scenarios.
I am completely confused on the namespaces in ExtJS5 application. I am using a common folder under the sencha workspace where I keep code I will be using for multiple pages (multiple SPA's). In one application definition I have the following snippet:
Ext.define('Admin.Application', {
extend: 'Ext.app.Application',
name: 'Admin',
namespaces: ['ALT'],
requires:[
'ALT.GlobalLib',
.....
In my common/src folder I have a file called AltGlobalLib.js with the following snippet:
Ext.define('ALT.GlobalLib',{
extend: 'Ext.app.Controller',
/**/
/** Custom Field Manipulation Methods
/**/
...
The file is loaded but I get a warning the the namespace for ALT.GlobalLib is missing and to add it to my Application Class namespace properties.Possible to get a firm example of how to properly separate the common code from the rest of the apps? Thanks!
I think you need to setPath and designate the name and folder.
Check out the docs on this. And particular setPath on Ext.Loader in the api docs
Here is an example:
Ext.Loader.setPath('NameSpace', '../path/to/files');