So, int ExtJS we have:
Ext.define
)The most enigmatic to me is alternateClassName. Why do we actually need them if we already have such a zoo of type descriptors? Note that I'm not trying to discuss the quality of the ideological approach. The question is only about why this was implemented and for what exactly purposes for.
In the HTML document, the className property is used to set or return the value of an element's class attribute. Using this property, the user can change the class of an element to the desired class. Syntax: returns the className property.
Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Try to keep your class names simple and descriptive. Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML).
While class names start with capital letters, methods should begin with a lowercase letter. Any other words you need as part of the method name will be uppercase. NO SPACES are allowed in the names! Also, since a method is an action (where the class is the blueprint), method names should be verbs.
It returns the Class object that represents the specified class name. This is used if you need to get the Class object. This roughly corresponds to . getClass() which returns the Class object that corresponds to the object instance.
They're used for backwards-compatibility. For example, Ext.grid.Panel in ExtJS 4 has
alternateClassName: ['Ext.list.ListView', 'Ext.ListView', 'Ext.grid.GridPanel']
because it replaces ListView and used to be named Ext.grid.GridPanel.
As per i know alternateClassName is helpful to call one class with diffrent names and we can use the actions as per class name.
The below code will be helpful for you:
Ext.define('Sample', {
alternateClassName: ['Example', 'Important'],
code: function(msg) {
alert('Sample for alternateClassName... ' + msg);
},
renderTo :document.body
});
var hi = Ext.create('Sample');
hi.code('Sample');
var hello = Ext.create('Example');
hello.code('Example');
var imp = Ext.create('Important');
imp.code('Important');
In the above code,you can find the things like:
1.We are using three names called Sample,Example,Important for one class.
2.We can use the action i.e., alert message according to the class name.
3.We are displaying the alert message based on the class name.Here we are displaying the alert message for showing the result.But we can write some actions according to the class name like,if we want to create one button and we need to write action on the button as per class name then this will be helpful.
You can fint the working sample below:
http://jsfiddle.net/kesamkiran/kVbra/30/
alias
An alias consists of a namespace and a name concatenated by a period as [namespace].[name]
Because of the namespace, its usage is restricted to context, e.g. widget, store, controller, etc (e.g. for a controller derived class you can use an alias like "controller.foo", and you can now use only "foo" name when attaching the controller to a view)
xtype
Only applies to Ext.Component derived classes
Useful when defining views because you write less code
alternateClassName
more general purpose than above two. you can use this for your utility classes, so you don't have to reference the whole namespace
For a singleton class used for storing constants declared as app.util.navigationConstants, you can define an alternate class name that is shorter, NavConsts. And you could now use NavConsts.CONST_NAME instead of app.util.navigationConstants.CONST_NAME
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With