자바스크립트/Ext JS
[Cookbook Study Ch01]9. Overriding Ext JS' Functionality - Part 2
베니94
2013. 5. 22. 16:28
Ext.onReady(function() { /*** * Date : 2013.05.22 * Desc : 아래 코드는 Ext.form.field.Text클래스를 override를 통해 기능을 변경한 예제이다. * * */ Ext.define('Cookbook.overrides.TextField', { override: 'Ext.form.field.Text', onRender: function(){ /*** * 기존 함수의 동작을 확장하기 위해 callParent를 사용한다. * 이때 필요한 인수를 전달하여 원래 함수를 호출할 수 있다. * 아래는 단순히 텍스트를 추가하는 방법을 보여준다. * 간단하게 onRender함수 실행시 간단한 텍스트를 모든 텍스트에서 * 동일하게 표시할 수 있도록 되었다. */ this.callParent(arguments); // executes the Ext.form.field.Text.onRender function // Ext.form.field.Text.superclass.onRender.apply(this, arguments); // executes the Ext.form.field.Base.onRender function Ext.core.DomHelper.append(this.el, '' + this.infoText + ''); } }); Ext.application({ name: 'Customer', launch: function(){ Ext.create('Ext.container.Viewport', { layout: 'fit', items: [{ xtype: 'form', title: 'Security Question Form', defaultType: 'textfield', items: [{ fieldLabel: 'Security Question', name: 'securityQuestion', allowBlank: false, infoText: 'You are required to write a security question for your account.' }, { fieldLabel: 'Security Answer', name: 'securityAnswer', allowBlank: false, infoText: 'Please provide the answer to your security question.' }] }] }); } }); }); // 출처 : Ext JS4 Web Application Development Cookbook