PDA

View Full Version : [RC2] IE8 not populating Combo box



fordprefect
4 Apr 2012, 2:41 PM
Hi,

I have a mvc application that has a combo box defined:



Ext.define('MyApp.view.canvas.Category', {
extend: 'Ext.form.field.ComboBox',
alias: 'widget.canvascategory',

emptyText: 'Select A Category',
fieldLabel: 'Category',
store: 'CategoryStore',
displayField: 'Name',
valueField: 'CategoryId'
});


with a store:



Ext.define('MyApp.store.CategoryStore', {
extend: 'Ext.data.Store',
model: 'MyApp.model.CategoryModel',

proxy: {
type: 'ajax',
url: '/MyApp/Canvas/GetCategories',
reader: {
type: 'json'
}
}
});


In IE8 the combo box does not contain any records, all the other browsers work fine in populating the store and combo box.

I tried to populate the store in the controller:



this.getStore("CategoryStore").load({
callback: function (records, operation, success) {
alert(records);
}
});


But the records reported a null value (again, in other browsers it was fine).

Is there a trick to creating stores so that they work in IE8 or have I missed something obvious?

Thanks for any ideas.

skirtle
5 Apr 2012, 2:08 AM
What does your JSON look like? Is it definitely valid, e.g. no stray commas?

Exactly which ExtJS build are you using?

Did this work against 4.0?

fordprefect
5 Apr 2012, 8:31 AM
Thanks for your response skirtle, your comment about commas sent me looking. The json string coming back was fine, however I had left a comma in my model defintion:



Ext.define('MyApp.model.CategoryModel', {
extend: 'Ext.data.Model',

fields: [
{ name: 'CategoryId', type: 'int' },
{ name: 'Name', type: 'string' },
]
});


Removing the comma allowed the store to load in IE8.

Cheers.

skirtle
5 Apr 2012, 8:40 AM
I'm going to move this thread to the Q&A forum.

Your JSON is invalid. It shouldn't contain all those slashes. I'm surprised it works in any browser, are you sure that's exactly what's coming back from the server?

fordprefect
5 Apr 2012, 8:45 AM
I'm going to move this thread to the Q&A forum.

Your JSON is invalid. It shouldn't contain all those slashes. I'm surprised it works in any browser, are you sure that's exactly what's coming back from the server?

Wow, you're fast - caught me in the edit.

My mistake, using fiddler the json response is:



[{"CategoryId":10,"Name":"Capital"},{"CategoryId":8,"Name":"Environment"},{"CategoryId":7,"Name":"Transportation"}]


Thanks again.