PDA

View Full Version : Combo dropdown seems to have a wrong size



Chau
6 Jan 2011, 6:04 AM
I have a combobox with a store that I manually updates. The store is updated from a out-of-house JSON webservice that does not provide the result as how ExtJS wants it. Thus I perform an AJAX request and manually inserts the response as records in the store.

When I input a search term, the combos list will be smaller than one line even though the list contains many records.

24139

How can I make sure the list has the correct height?


xtype: 'combo',
id: 'mycombo',
fieldLabel: 'mylabel',
displayField: 'displayName',
valueNotFoundText: 'value not found',
listEmptyText: 'list empty',
loadingText: 'loading',
emptyText: 'input here',
enableKeyEvents: true,
anchor: '100%',
mode: 'local',
store: new Ext.data.ArrayStore(
{
fields: ['id', 'displayName', 'x', 'y'],
data: []
}),
listeners:
{
keyup: function (textfield, event) {
if (textfield.lastQuery != textfield.getRawValue()) {
this.requestData(textfield.getRawValue());
}
},
scope: this
}

requestData: function (searchTerm) {
// Do AJAX request...
// ...

// On success:
this.fillSearchResults(response);
}

fillSearchResults: function (results) {
var combo = Ext.getCmp('mycombo');

// Remove all previous records.
combo.store.removeAll();
var recordType = combo.store.recordType;
for (var index = 0; index < results.length; index++) {
var result = results[index];
var record = new recordType({
id: index,
displayName: result.displayName,
x: result.x || 0,
y: result.y || 0
});
combo.store.add(record);
}

// Make sure the list is expanded.
combo.expand();
}