alguien me puede ayudar con la forma de extender los componentes extjs utilizando extjs versión 4. Estoy buscando una sintaxis adecuada para el mismo. por favor ayuda..!!ExtJs 4 ... ¿Cómo extender los componentes de Extjs 4?
Respuesta
por qué no ver en la Colección de los componentes del extjs4, tales como GRID, Mesa ...
y aquí están docs:
http://docs.sencha.com/ext-js/4-0/#/guide/components < == importante
http://docs.sencha.com/ext-js/4-0/#/guide/class_system
Ext.define('My.custom.Component', {
extend: 'Ext.Component'
});
Ext.define('myApp.Grid', {
extend: 'Ext.Grid',
alias: 'widget.mygrid'
....
....
}
ahora puedes usar xtype: 'myg deshacerse'
siguiente es un ejemplo de código de campo de texto se extiende en ExtJS 4.
Otros a continuación, utilizando las configuraciones y los métodos existentes, este componente extendido también tiene una nueva propiedad config creado y un nuevo método creado & asociado con una evento.
El propósito del componente es simple que muestra la etiqueta en color rojo si el valor es obligatorio, modifica el color de fondo del campo si solo es read y también cambia el color de fondo del campo cuando está enfocado.
El código está correctamente comentado. Espero eso ayude.
Ext.define('Ext.pnc.Textfield', {
extend: 'Ext.form.field.Text',//Extending the TextField
alias: 'widget.pnctextfield',//Defining the xtype
config:{
focusCls:'focusClassFieldPnC',//Providing value for existing config property.
testConfig:'testConfigValue'//Creating a new config. Accessor functions will be created for this one by ExtJS engine
},
constructor:function(cnfg){
this.callParent(arguments);//Calling the parent class constructor
this.initConfig(cnfg);//Initializing the component
this.on('beforerender',this.beforeRender);//Associating a new defined method with an event
},
//Defining a method below and associating this with an event in the constructor above
beforeRender:function(){
if(!this.allowBlank){
this.labelStyle = 'color:#FF0000';
}
if(this.readOnly){
this.fieldCls = 'readOnlyClass';
}
},
//Over-riding a function which already exists in parent class. Note that this has not been associated with any event in constructor as it already defined in parent class
afterRender:function(){
console.log('after render function');
this.callParent();//Calling the parent class method. This can be omitted if not required and is not a must
}
});
.readOnlyClass{
background:#FF0000 !important
}
.focusClassFieldPnC{
background:#00ff00 !important
}
Ext.define('BS.view.MyGrid' , {
extend: 'Ext.grid.Panel',
alias: 'widget.my-grid',
// Non-complex config types (booleans, integers, strings) go here
width: 1000,
autoHeight: true
initComponent: function() {
Ext.apply(this, {
// complex configs (objects/arrays) go here
columns: colModel,
});
this.callParent(arguments);
}
});
- 1. Extjs 3 a Extjs 4
- 2. ExtJS ComboBox 4 Autocompletar
- 3. ExtJS 4 code assist
- 4. Extjs 4 Grid findcolumn
- 5. Componente Extjs dentro de Ext.XPlantilla en EXTJS 4
- 6. Renderizar componentes dinámicos en ExtJS 4 GridPanel Columna con Ext.create
- 7. ExtJS 4 Convenciones de nomenclatura
- 8. Best ExtJs 4 theme resource
- 9. rutas relativas utilizando extjs 4
- 10. Modelo dinámico con ExtJS 4
- 11. Cómo obtener elemento hijo en ExtJS 4
- 12. Cómo empaquetar (minify) una aplicación extjs 4
- 13. ¿Cómo usar Ext.define en ExtJS 4?
- 14. Cómo ocultar la pestaña en ExtJS 4
- 15. Extjs 4 Valor predeterminado de combobox
- 16. EXTJS 4 - Oyente de excepción global
- 17. ExtJS 4 - ¿Eventos de celdas de cuadrícula?
- 18. Extjs 4 casilla de verificación no visible
- 19. ¿Cómo reutilizo los componentes en ExtJS?
- 20. ExtJS 4: Rejillas/Tiendas sin modelos
- 21. ExtJS 4 - Problemas con JsonStore + Post Request
- 22. ¿Cómo se realiza la herencia del controlador en ExtJS 4?
- 23. Extjs 4 con Sencha Touch Scrollbar
- 24. Columna ExtJS 4 "Renderer" en la cuadrícula
- 25. Metodología de aprendizaje de ExtJs 4 más rápida
- 26. ¿Cómo obtener el mensaje de respuesta REST en ExtJs 4?
- 27. Panel ExtJs: agregar componentes dinámicos
- 28. ExtJS 4 - ¿Cómo editar condicionalmente una celda en una cuadrícula?
- 29. Envío de un formulario + cuadrícula en ExtJS 4
- 30. Controlador de extensión en la aplicación ExtJS 4 MVC
El ejemplo podría ser aún más explicativo si realmente se utiliza la configuración personalizada que haya definido. – Muxecoid
Gracias por callParent en constructor, ¡resolvió mis problemas! No está incluido en el docu oficial. Docu dice que solo initConfig es suficiente ... – ArcanisCz