Results 1 to 2 of 2

Thread: A problem about the focus of the combo, after load form it always focus on a combo?!

  1. #1
    Sencha User
    Join Date
    Mar 2008
    Posts
    82

    Default A problem about the focus of the combo, after load form it always focus on a combo?!

    Hi, i have a problem now

    I have a formpanel with comboboxes

    but when i open the formpanel
    it always focus on the last combox instead of the first item.

    and the focused combobox will display it's drop down list also.

    Anyone knows how to resolve this?

    this is my code:

    Code:
    MyFormPanel = function(){
    myStore1 = new Ext.data.JsonStore({
                        url : url1,
    		    fields : ['id', 'text']
                 });
    myStore1.load();
    myStore2 =  new Ext.data.JsonStore({
                        url : url2,
    		    fields : ['id', 'text']
                 });
    myStore2.load();
    
    MyFormPanel.superclass.constructor.call(this, {
    title:'My Form',
    width : 400,
    height: 600,
    items:[
    {
    xtype:'textfield',
    name:'field1',
    fieldLabel : 'Field1'
    },
    {
    xtype:'combo',
    fieldLabel : this.COLUMNS.AGENT_ORGANIZATION.TITLE,
    name : this.COLUMNS.AGENT_ORGANIZATION.DATA_INDEX,
    hiddenName : "id1",
    name:'combo1',
    valueField : 'id',
    displayField : 'text',
    store : myStore1,
    triggerAction : 'all',
    mode : 'remote',
    minChars : 1,
    forceSelection : true,
    selectOnFocus : true
    },
    {
    xtype:'combo',
    fieldLabel : this.COLUMNS.AGENT_ORGANIZATION.TITLE,
    name : this.COLUMNS.AGENT_ORGANIZATION.DATA_INDEX,
    hiddenName : "id2",
    name:'combo2'
    valueField : 'id',
    displayField : 'text',
    store : myStore2,
    triggerAction : 'all',
    mode : 'remote',
    minChars : 1,
    forceSelection : true,
    selectOnFocus : true
    }
    ]
    });
    }
    
    
    Ext.extend(MyFormPanel, Ext.FormPanel, {});

    And i overrider the setValue function for the combo to set the value when the store is not loaded:
    Code:
    Ext.override(Ext.form.ComboBox, {
    			setValue : function(v) {
    				if (this.hiddenName && this.mode == 'remote'
    						&& this.store.getCount() <= 0)
    					this.store.load({
    								callback : function() {
    									this.setRawValue(v);
    								}.createDelegate(this)
    							});
    				else {
    					this.setRawValue(v);
    				}
    				return this;
    			},
    			setRawValue : function(v) {
    				var text = v;
    				if (this.valueField) {
    					var r = this.findRecord(this.valueField, v);
    					if (r) {
    						text = r.data[this.displayField];
    					} else if (Ext.isDefined(this.valueNotFoundText)) {
    						text = this.valueNotFoundText;
    					}
    				}
    				this.lastSelectionText = text;
    				if (this.hiddenField) {
    					this.hiddenField.value = Ext.value(v, '');
    				}
    				Ext.form.ComboBox.superclass.setValue.call(this, text);
    				this.value = v;
    				return this;
    			}
    		});
    i hope that when the combo's value is setted, it will load the store automatically and set the value after the store is loaded.

    but, the problem comes!

    when i load the form by form.load(), and the form is displayed
    the form will focus on the last combobox instead of the first texstfield

    Anyone can help me to correct the problem?

  2. #2

Similar Threads

  1. Focus problem in combo boxes
    By nitinfuture in forum Ext GWT: Discussion
    Replies: 2
    Last Post: 26 Jul 2010, 8:26 AM
  2. Setting focus to combo causes expand?
    By TopKatz in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 6 Jan 2010, 6:15 PM
  3. filterby on focus combo
    By nahawand in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 13 Sep 2009, 1:53 AM
  4. Combo and EditorGrid focus
    By buzzterrier in forum Ext GWT: Help & Discussion (1.x)
    Replies: 1
    Last Post: 22 Aug 2009, 5:48 AM

Posting Permissions

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