Skip to content

Instantly share code, notes, and snippets.

@dmackerman
Created August 5, 2011 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmackerman/1128565 to your computer and use it in GitHub Desktop.
Save dmackerman/1128565 to your computer and use it in GitHub Desktop.
Custom ComboBox class
Ext.ns('IbwUi.controls');
IbwUi.controls.ComboBoxJSON = Ext.extend(Ext.form.ComboBox, {
url: '',
root: '',
valueField: 'id',
displayField: 'name',
listWidth: 200,
width: 200,
initComponent: function () {
var comboStoreJson = new Ext.data.JsonStore({
idProperty: 'id',
autoDestroy: true,
autoLoad: true,
root: this.root,
fields: this.fields || [{
name: 'id',
type: 'int'
}, {
name: 'name',
type: 'string'
}],
sortInfo: {
field: this.displayField,
direction: 'ASC'
},
proxy: new Ext.data.ScriptTagProxy({
api: {
read: this.url
}
})
});
var config = {
autoSelect: true,
store: comboStoreJson,
displayField: this.displayField,
valueField: this.valueField,
mode: 'remote',
forceSelection: true,
minChars: 1,
triggerAction: 'all',
lastQuery: '',
typeAhead: true,
typeAheadDelay: 50,
lazyRender: true,
lastQuery: '',
value: this.value,
listWidth: this.width + 200,
width: this.width,
listeners: {}
};
Ext.apply(this, config);
IbwUi.controls.ComboBoxJSON.superclass.initComponent(this);
}
});
Ext.reg("ibwComboJson", IbwUi.controls.ComboBoxJSON);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment