2010-11-01 80 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()); 
    } 
}); 
相关问题