Skip to content

Instantly share code, notes, and snippets.

@cjauvin
Created December 11, 2012 22:22
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 cjauvin/4262874 to your computer and use it in GitHub Desktop.
Save cjauvin/4262874 to your computer and use it in GitHub Desktop.
Ext.onReady(function() {
Ext.define('Ubuntu', {
extend: 'Ext.data.Model',
fields: [{
name: 'release',
convert: function(v, rec) {
return Ext.String.format('{0} {1} - {2}',
rec.raw.adjective,
rec.raw.animal,
rec.raw.version);
}
}]
});
Ext.create('Ext.panel.Panel', {
renderTo: Ext.getBody(),
title: 'Ubuntu Releases',
width: 300,
bodyPadding: 10,
layout: 'anchor',
draggable: true,
style: 'margin: 20px',
items: [{
xtype: 'combo',
store: Ext.create('Ext.data.Store', {
model: 'Ubuntu',
proxy: {
type: 'ajax',
url: '/backend/autocomplete',
reader: {
type: 'json',
root: 'data'
}
}
}),
typeAhead: true,
displayField: 'release',
hideLabel: true,
anchor: '100%',
minChars: 3,
listConfig: {
loadingText: 'Searching...',
emptyText: 'No matching release found'
}
}, {
xtype: 'component',
style: 'margin-top:10px',
html: 'Type at least 3 characters to trigger search'
}]
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment