Showing posts with label combobox. Show all posts
Showing posts with label combobox. Show all posts

Monday, 8 April 2013

How to avoid showing old data on extjs comobox while querying.

Problem:  When I click on combobox. It shows the old data in blur before it display new data. Some time it does not  allow me to select  the combobox.  Those kind of issue will appear only when you load combobox as raw static data and then try to load using query.

Solution:

        xtype: 'combobox',
        name: 'interNalFaeId',
        itemId: 'interNalFaeId',
        fieldLabel: 'Arrow FAE',
        editable: false,
        listeners: {
          beforequery: function(queryEvent) {
            if (queryEvent.combo.lastQuery !== queryEvent.query) {
              queryEvent.combo.store.removeAll();
            }
          },
          scope: me

        }

How to handle special key TAB or ENTER for EXTJs combobox to trigger.

Requirement is to trigger EXTJS combobox to trigger on tab change and press of enter key.
Below code is solution for above requirement.

        xtype: 'partsearchlov',
        name: 'partNumber',
        displayField: 'concatSegPartNum',
        valueField: 'concatSegPartNum',
        fieldLabel: 'Arrow Part',
        allowBlank: false,
        cls: 'required',
        minChars: 2,
        triggerAction: 'query',
        labelWidth: 80,
        listeners: {
          specialkey: function(field, e) {
            var val;
            if (e.getKey() === e.ENTER || e.getKey() === e.TAB) {
              val = field.getRawValue();
              if ( typeof val !== 'undefined') {
                if (val.indexOf('^') !== -1) {
                  val = val.slice(0, val.indexOf('^'));
                }
                field.doQuery(val, true, true);
              }
            }
          },
          scope: me

        }

Tuesday, 15 May 2012

How to pass extra parameter to extjs combo

I have to one scenario, Suppose there are two combo ,I need to pass first one value as parameter of second combo query param.
Let say i have two combos in form
items:[
{
 fieldLabel: 'Customer Name',
 xtype:'customerlovcombo',
 width:550,
 id:'form-field-custproj-cust-name'
},
{
 fieldLabel: 'Project Name',
 xtype:'projectlovcombo',
 width:550,
 id:'form-field-custproj-proj-name'
}
]

Here i want to pass customerId as part of  proejctlovcombo.
What we need to do is in controller user beforequery to pass extra param as part of  proejctlovcombo

init: function() {
    '#form-field-custproj-proj-name':{
    beforequery:this.formatQuery
    }
},

formatQuery: function(queryEvent) {
var custName = Ext.getCmp('form-filed-cust-name').getRawValue();
 if(custName !=null && custName != ""){
  queryEvent.combo.getStore().getProxy().extraParams.custName=custName;
  }
}