如何设置在extjs中选择Combobox中的索引宽度

时间:2010-11-01 07:07:58

标签: php extjs

我在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);

                  }
              }
         }

1 个答案:

答案 0 :(得分:1)

您应该通过跳过{xtype ='combo'}位并使用其完整类型声明对象来正确实例化ComboBox(在您的示例中使用延迟实例化):

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());
  }
});