PDA

View Full Version : Can't LOAD data into my JSONStore.



Yoda
5 Oct 2009, 3:59 PM
<html>

<head>
<title>EXT JS: Test Project</title>
<link rel="stylesheet" type="text/css" href="lib/extjs/resources/css/ext-all.css" />
<style>
.milton-icon {
background: url(img/user_gray.png) no-repeat;
}
</style>
<script src="lib/extjs/adapter/ext/ext-base.js"></script>
<script src="lib/extjs/ext-all-debug.js"></script>
<script>
var proxy = new Ext.data.HttpProxy({
url: 'data/genres.html'
});

var reader = new Ext.data.JsonReader({
fields: ['id', 'genre_name'],
root: 'rows'
});

var store = new Ext.data.Store({
proxy: proxy,
reader: reader
});

store.load();
Ext.onReady(function(){
Ext.QuickTips.init();

Ext.form.VTypes['nameVal'] = /^([A-Z]{1})[A-Za-z\-]+([A-Z]{1})[A-Za-z\-]+$/;
Ext.form.VTypes['nameMask'] = /[A-Za-z\- ]/;
Ext.form.VTypes['nameText'] = 'In-valid Director Name.';
Ext.form.VTypes['name'] = function(v){
return Ext.form.VTypes['nameVal'].test(v);
}

var movie_form = new Ext.FormPanel({
url: 'movie-form-submit.php',
renderTo: document.body,
frame: true,
title: 'Movie Information Form',
width: 250,
items: [{
xtype: 'textfield',
fieldLabel: 'Title',
name: 'title',
allowBlank: false,
vtype: 'alpha',
listeners: {
specialkey: function(f,e){
if (e.getKey() == e.ENTER) {
movie_form.getForm().submit();
}
}
}
},{
xtype: 'textfield',
fieldLabel: 'Director',
name: 'director',
allowBlank: false,
vtype: 'name'
},{
xtype: 'datefield',
fieldLabel: 'Released',
name: 'released',
disabledDays: [1,2,3,4,5]
},{
xtype: 'radio',
fieldLabel: 'Filmed In',
name: 'filmed_in',
boxLabel: 'Color'
},{
xtype: 'radio',
hideLabel: false,
labelSeparator: '',
name: 'filmed_in',
boxLabel: 'Black & White'
},{
xtype: 'checkbox',
fieldLabel: 'Bad Movie',
name: 'bad_movie'
},{
xtype: 'combo',
name: 'genre',
fieldLabel: 'Genre',
store: store,
displayField:'genre_name',
width: 120
},{
xtype: 'htmleditor',
name: 'description',
hideLabel: true,
labelSeparator: '',
height: 100,
anchor: '100%'
}],
buttons: [{
text: 'Save',
handler: function(){
movie_form.getForm().submit({
success: function(f,a){
Ext.Msg.alert('Success', 'It worked');
},
failure: function(f,a){
Ext.Msg.alert('Warning', 'Error');
}
});
}
}, {
text: 'Reset',
handler: function(){
movie_form.getForm().reset();
}
}]
});
});
</script>
</head>

<body>


</body>
</html>




Here is my server side json response:



{"rows":[{"id":1,"genre_name":"Comedy"},{"id":2,"genre_name":"Horror"},{"id":3,"genre_name":"Suspense"}]}




i'm trying to load this data into my combo-box(drop-down list)...

somehow...nothing happens...i figured that something is wrong with my store...

can anyone help me with this??? im really really new to EXT JS..........

jarlau
5 Oct 2009, 6:48 PM
are you running this on the web server? or just locally?

MiamiCoder
5 Oct 2009, 7:02 PM
Did you try triggerAction (http://www.extjs.com/deploy/ext-3.0.0/docs/source/Combo.html#cfg-Ext.form.ComboBox-triggerAction):'all' in your combo?