开发者

How to set Select index width in Combobox at extjs

开发者 https://www.devze.com 2023-01-23 02:51 出处:网络
I am having problem to give the width in Select index for a combobox in extjs. My Code is below; var inventorytbar = [

I am having problem to give the width in Select index for a combobox in extjs.

My Code is below;

var inventorytbar = [
   {
             xtype: 'combo',
             text: 'Filter Category',
             hiddenName: 'local-states',
             store: storeCat,
             displayField: 'state',
             typeAhead: true,
      开发者_JAVA百科       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);

                  }
              }
         }


You should instantiate the ComboBox properly (in your example you are using lazy instantiation) by skipping the {xtype='combo'} bit and declaring the object with its full type:

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

Add a listener to wait until selection, the page will be rendered at this stage so you can use ComboBox.view.getNode(Ext.data.Record record) like this:

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

精彩评论

暂无评论...
验证码 换一张
取 消