PDA

View Full Version : Can't Get Data Loaded into Form Fields



1 Jun 2011, 8:11 PM
I am trying to use the code structure from the Sencha Touch Kitchen Sink example. When making a selection from the navigation panel I am display a form in the main panel... all this is working fine. Now I am trying to load values into the form fields from a data model populated from a json ajax source. I can not get the form field values to display in the form. In the console I see the ajax script called and also see the json string returned and there are no errors.

I've treid countless modifications to this code taken from the forum to load the form field values with no success. Any help would be greatly appreciated.



npi.ProdDetailsModel = Ext.regModel('ProdDetails', {
fields: [
{name: 'Product_Name', type: 'string'},
{name: 'ProductID', type: 'string'}
],
proxy: {
type: 'ajax',
url : '/cgi/npi_mobile_json.pl?method=ProductDetails'
}
});

npi.ProdDetailsModelInstance = Ext.ModelMgr.getModel('ProdDetails');

npi.ProductDetailsForm = new Ext.form.FormPanel({
scroll: 'vertical',
items: [{
title: 'Basic',
id: 'basicform',
items: [{
xtype: 'fieldset',
title: 'Personal Info',
instructions: 'Please enter the information above.',
defaults: {
// labelAlign: 'right'
labelWidth: '35%'
},
items: [{
xtype: 'textfield',
name: 'ProductID',
id: 'ProductID',
label: 'Product ID'
}, {
xtype: 'textfield',
name: 'Product_Name',
id: 'Product_Name',
label: 'Product_Name'
}]
}]
}]
});

npi.ProdDetailsModelInstance.load(123, {
success: function(prod) {
console.log(prod.get('Product_Name'));
}
});

npi.ProductDetailsForm.loadRecord(npi.ProdDetailsModelInstance);