I have created the class in Ext JS 4, and now I want to extend that in another class. I use extend
properties, to extend the class. But I am not able to extend the class. Do I want to use require to include the class file. But I keep both the files in the same directory.
Asked
Active
Viewed 472 times
0

Boopathy
- 367
- 1
- 7
- 16
-
check http://stackoverflow.com/questions/6290729/how-to-use-ext-define-in-extjs4/6455079 – Jom Jul 13 '12 at 11:25
1 Answers
0
Define source paths for ExtJS to locate your source files.
Ext.Loader.setConfig({
enabled: true,
paths: {
'[your namespace prefix here]': '[physical path]'
}
});
Then define Ext.require
or requires
section in subclass to enable automatic path resolution.
Read this link for more info.
Example
Base class: file located at folder root/view/common/Picker.js
Ext.define('RL.view.common.Picker', {
extend: "Ext.form.field.Picker",
...
}
Sub class: file located at folder root/view/selection/DriverTreeCombo.js
Ext.define('RL.view.selection.DriverTreeCombo', {
extend: "RL.view.common.Picker",
requires: ['Ext.tree.Panel', 'RL.view.common.TreeBase'],
...
}
I have namespace as RL.xxx.xxx and RL is supposed to be the root
folder. Now I can define Loader configuration as below
Ext.Loader.setConfig({
enabled: true,
paths: {
'RL': '/root'
}
})
Loader configuration should be set before 'Ext.onReady(...)' function call. Going through examples folder in ExtJS package would help you to see how this is done.
Further reading:

jorel
- 808
- 7
- 15
-
Thank you.. But where exactly we want to use this code. We have to create a seperate file, or can write in the js file, where we extend our own class file? – Boopathy Jul 13 '12 at 13:31
-
Hey colombo, Could you send me the fully functional code for this. Im not able to do it, it shows 'Exception Thrown and not caught' error. – Boopathy Jul 13 '12 at 14:20
-
I have edited my answer again. See the Further reading links at the end. It will help. – jorel Jul 13 '12 at 14:29
-
You will find a downloadable ZIP file with a example at the end of Dynamic Loading and New class system page. – jorel Jul 13 '12 at 14:32