PDA

View Full Version : jsonReader ComboBox Question



StevenInc
18 Jul 2009, 11:45 AM
I am very new to EXT JS, so first off I want to express my gratitude to anyone who takes the time to respond.

I bought the book "Learning Ext JS" by
Colin Ramsay (http://www.packtpub.com/author_view_profile/id/270), Shea Frederick (http://www.packtpub.com/author_view_profile/id/269), Steve 'Cutter' Blades (http://www.packtpub.com/author_view_profile/id/271) and in the book they give an incomplete example of populating a combobox with a JSON data feed from a PHP server. I have been attempting to recreate this example but I am having no success at it. There is a catch, I am not using a PHP server. I am using a coldfusion 8 server. I wrote a static .cfm template (chap3PHPformatedData.cfm) to return the following PHP formated json data set:

{rows:[{"id":"1","genre_name":"Comedy","sort_order":"0"},{"id":"2","genre_name":"Drama","sort_order":"1"},{"id":"3","genre_name":"Mystery","sort_order":"2"}]}

The script that call the dataset looks like this:

<script>
Ext.onReady(function(){
Ext.BLANK_IMAGE_URL = '../images/s.gif';

var genres = new Ext.data.Store({
reader: new Ext.data.JsonReader({
fields: ['id', 'genre_name'],
root: 'rows'
}),
proxy: new Ext.data.HttpProxy({
url: 'data/chap3PHPformatedData.cfm'
}),
autoLoad: true
});
//genres.load();


new Ext.FormPanel({
url: 'movie-form-submit.cfm',
renderTo: document.body,
frame: true,
title: 'Movie Information Form',
width: 250,
items: [{
xtype: 'combo',
name: 'genre',
fieldLabel: 'Genre',
mode: 'local',
store: genres,
displayField:'genre',
valueField: 'id',
width: 130,
triggerAction: 'all',
emptyText: 'Select a state...'
}]
});
});
</script>

The Ajax call seems to work and I can view the response text in firebug, but the combo box does not populate the drop down options.


Thank you for your help.
Steven Benjamin

Animal
18 Jul 2009, 12:22 PM
displayField:'genre',


and



fields: ['id', 'genre_name'],


:-?

StevenInc
18 Jul 2009, 1:11 PM
That was the problem :)