Results 1 to 3 of 3

Thread: Container's "defaults" cannot apply to children items

  1. #1
    Sencha Premium Member
    Join Date
    May 2013
    Posts
    48
    Answers
    1

    Default Answered: Container's "defaults" cannot apply to children items

    I have a window with a form. After window opening, the form has no components items in the beginning, it uses its own function "putData2Store" to creates stores. After stores has been created, there is a callback function to call the function "dispatch" to add extra items in form.

    I met a problem, my form has its own defaults attribute --> defaults: {labelWidth:400}, I expect that labelWidth:400 will work on my textfield "des" but it doesn't.

    Code:
    Ext.define('zldapp.view.securepolicy.policy.secpolicyedit', {
    	extend:'Ext.zyWindow',	
    	initComponent: function(){
    		var me = this; 
    		Ext.apply(this, {
    			title: 'add',
    			id: 'secpolicyedit',
    			width: 800,
    			height: 430,
    	 
    			iconCls: 'add',
    	 
    			ok: function(){
    				var form = this.query('#security-policy-edit');
    				form[0].cfgCLI(this.which);
    			},
    			cancel: function(){
    				this.close();
    			},
    			items:[{
    				xtype: 'zyform',    
    				id:'security-policy-edit',
    				defaults:{
    	 
    					labelWidth:400
    				},
    	   
    			   putData2Store: function(form){
    		 
    					//create store here
    					...
    		  
    			   },
    			   buildItems: function(){
    					var which = me.which;
    					var name = (which.action == 'edit') ? which.rowSel.get('__name') : '';
    					var des = Ext.create('Ext.zyTextField',{
    					 
    					fieldLabel: mlang['_Description'],
    					name: 'description',
    					id: 'desc',
    					vtype: 'chkDesc',
    					value: (which.action == 'add') ? '' : which.rowSel.get('_description'),
    					previousValue: (which.action == 'add') ? '' : which.rowSel.get('_description'),
    					listeners: {
    						render: function(e) {
    							if (name == 'Default')
    								e.setVisible(false);
    							},
    							change: function(e) {
    							if (which.action == 'edit')
    								handleFn(which.rowSel, '_description', e.getValue(), e.previousValue);
    							} 
    					},
    					hypertext:{
    						text:'',
    						tabId:'',
    						treeNodeId:''
    					},
    					inote:'',
    					suffix:'('+mlang['_Optional']+')'
    					 
    					});
    
    
    					return[
    						{
    							xtype: 'zyformspacer'
    						},
    						 
    						des,
    						{
    							xtype: 'zyformspacer'
    						}
    					];
    				},
    				dispatch: function(){
    					this.add(this.buildItems());
    					this.doLayout();
    				}
    	 
    			}]
    	 
    		});
    		 
    		this.callParent();
    	}
    });
    If I don't create "des" first, I use "xtype" instead, it works perfectly, the labelWidth of "des" is set as 400 as I want.
    Could anyone tell me what's the difference between them? I don't want to change all the old version code for 4.2 upgrade >.<


    The code below works
    Code:
    var des = { 
        xtype:'zytextfield',
    	fieldLabel: mlang['_Description'],
    	name: 'description',
    	id: 'desc',
    	vtype: 'chkDesc',
    	value: (which.action == 'add') ? '' : which.rowSel.get('_description'),
    	previousValue: (which.action == 'add') ? '' : which.rowSel.get('_description'),
    	listeners: {
    		render: function(e) {
    			   if (name == 'Default')
    					e.setVisible(false);
    		},
    		change: function(e) {
    				if (which.action == 'edit')
    					 handleFn(which.rowSel, '_description', e.getValue(), e.previousValue);
    		} 
        }
    }

  2. Wouldn't the form property "fieldDefaults" work the way you want?

    http://docs.sencha.com/extjs/4.1.3/#...-fieldDefaults

    -Chris

  3. #2
    Ext JS Premium Member cmeans's Avatar
    Join Date
    Jun 2010
    Location
    Chicago, IL USA
    Posts
    117
    Answers
    3

    Default

    Wouldn't the form property "fieldDefaults" work the way you want?

    http://docs.sencha.com/extjs/4.1.3/#...-fieldDefaults

    -Chris

  4. #3
    Sencha Premium Member
    Join Date
    May 2013
    Posts
    48
    Answers
    1

    Default

    Hi Chris,Thank you very much! I don't know there is a "fieldDefaults" from 4.0, it works. I appreciate that you told me this.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •