Cipher
21 Jun 2007, 7:52 AM
Hi, I'm trying make a Ext Form.
My Ext Code:
docForm = function(){
fds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: '/getDoc.php'}),
reader: new Ext.data.JsonReader(
{root: 'rows', id: 'id'},
[
{name: 'id'},
{name: 'title'}
]
)
});
fds.load({params:{id: docId},scope: this});
alert(fds.getAt(0)); // it appears "undefined".
//constructor
docForm.superclass.constructor.call(this, domFormId,{
labelWidth: 75,
url: 'save-form.php'
});
this.add(
new Ext.form.TextField({
fieldLabel: 'Title',
name: 'title',
value: fds.title, //I'm trying put value from JSON here
width: '400',
allowBlank: false
})
);
this.addButton('Save');
this.addButton('Cancel');
this.render('abc');
}
Ext.extend(docForm, Ext.form.Form, {
})
My JSON data :
{"rows":[
{"id":14,"title":"test"},
{"id":15,"title":"test1"},
{"id":16,"title":"test2"}
]}And FireBug review is attached.
My question is how to get JSON value in Form?
I tried to search forums posts and tried to change my JSON format, but it doesn't work. What's wrong with my code?
My Ext Code:
docForm = function(){
fds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: '/getDoc.php'}),
reader: new Ext.data.JsonReader(
{root: 'rows', id: 'id'},
[
{name: 'id'},
{name: 'title'}
]
)
});
fds.load({params:{id: docId},scope: this});
alert(fds.getAt(0)); // it appears "undefined".
//constructor
docForm.superclass.constructor.call(this, domFormId,{
labelWidth: 75,
url: 'save-form.php'
});
this.add(
new Ext.form.TextField({
fieldLabel: 'Title',
name: 'title',
value: fds.title, //I'm trying put value from JSON here
width: '400',
allowBlank: false
})
);
this.addButton('Save');
this.addButton('Cancel');
this.render('abc');
}
Ext.extend(docForm, Ext.form.Form, {
})
My JSON data :
{"rows":[
{"id":14,"title":"test"},
{"id":15,"title":"test1"},
{"id":16,"title":"test2"}
]}And FireBug review is attached.
My question is how to get JSON value in Form?
I tried to search forums posts and tried to change my JSON format, but it doesn't work. What's wrong with my code?