henrymuro
9 Jan 2012, 5:42 PM
I am struggling with the proper use of loadRecord to populate a Form Panel in Sench Touch 1.1. I have searched the forums and still can not figure this out. I stripped down my form to the bare minimum trying to get it to work and now I am stuck. Any help is appreciated. Here is my stripped down code
Ext.setup({
onReady: function() {
var projectModel = Ext.regModel('projModel', {
fields: [
{name: 'project_id', type: 'string'},
{name: 'project_name', type: 'string'}
]
});
var projectStore = new Ext.data.JsonStore({
model : 'projModel',
storeId: 'projStore',
autoLoad: true,
fields: [
{name: 'project_id', type: 'string'},
{name: 'project_name', type: 'string'}
],
proxy: {
type: 'ajax',
url: 'project.json',
reader: {
type: 'json'
}
}
});
var projectForm = new Ext.form.FormPanel({
fullscreen: true,
id: 'projForm',
dockedItems:[
{
xtype: 'toolbar',
dock: 'top',
title: 'Project 1',
}
],
items: [
{
xtype: 'textfield',
label: 'Project ID',
name: 'project_id'
},
{
xtype: 'textfield',
label: 'Project Name',
name: 'project_name'
},
]
});
var record = projectStore.getAt(0);
projectForm.loadRecord(record);
}
});
project.json returns the following
[{"project_id": "1211", "project_name": "My test Project"}]
Both the fields in the store and form match but the form is still not getting populated with the data
Ext.setup({
onReady: function() {
var projectModel = Ext.regModel('projModel', {
fields: [
{name: 'project_id', type: 'string'},
{name: 'project_name', type: 'string'}
]
});
var projectStore = new Ext.data.JsonStore({
model : 'projModel',
storeId: 'projStore',
autoLoad: true,
fields: [
{name: 'project_id', type: 'string'},
{name: 'project_name', type: 'string'}
],
proxy: {
type: 'ajax',
url: 'project.json',
reader: {
type: 'json'
}
}
});
var projectForm = new Ext.form.FormPanel({
fullscreen: true,
id: 'projForm',
dockedItems:[
{
xtype: 'toolbar',
dock: 'top',
title: 'Project 1',
}
],
items: [
{
xtype: 'textfield',
label: 'Project ID',
name: 'project_id'
},
{
xtype: 'textfield',
label: 'Project Name',
name: 'project_name'
},
]
});
var record = projectStore.getAt(0);
projectForm.loadRecord(record);
}
});
project.json returns the following
[{"project_id": "1211", "project_name": "My test Project"}]
Both the fields in the store and form match but the form is still not getting populated with the data