2010-11-01 40 views
1

我有問題在extjs的組合框的Select索引中給出寬度。如何設置在組合框中選擇索引寬度在extjs

我的代碼如下;

var inventorytbar = [ 
    { 
      xtype: 'combo', 
      text: 'Filter Category', 
      hiddenName: 'local-states', 
      store: storeCat, 
      displayField: 'state', 
      typeAhead: true, 
      mode: 'local', 
      triggerAction: 'all', 
      autoWidth: true, 
      editable:false, 
      value: 'All Inventory', 
      selectOnFocus:true, 
      boxMaxWidth: 500, 

      listeners: 
       { 
        'select': function (combo, record, index) 
        { 
         var catid = record.get('abbr'); 
         selectedComboCat = catid; 
         var catname = record.get('state'); 
         var newcatname = catname.replace(/ /g, ''); 
         combo.setValue(newcatname); 

        } 
       } 
     } 
+0

爲什麼你設置'php'標籤? – pltvs 2010-11-01 07:50:21

+0

你想設置選擇框的寬度,或者得到它? – SW4 2010-11-01 09:09:08

回答

1

你應該跳過{的xtype =「二合一」}位,並用它的全部類型聲明該對象正確實例化的組合框(在你的例子中,你正在使用延遲實例):

var inventorytbar = [ 
    this.theCombo = new Ext.form.ComboBox({ 
    // Your config settings 
    }); 
] 

添加一個偵聽器要等到選擇,網頁會在這一階段呈現,所以你可以使用ComboBox.view.getNode(Ext.data.Record記錄)這樣的:

this.theCombo.on('select', function(combo, record, index) { 
    if (combo.view) { 
    var node = combo.view.getNode(record); 
    if (node && Ext.fly(node)) alert(Ext.fly(node).getWidth()); 
    } 
}); 
相關問題