PDA

View Full Version : issue with adding store with XML data into a textField



Pilinir
23 May 2012, 9:34 AM
Hello,
I am trying to read from an xml and then display the information inside a text field in a form. From what I can read in my console log it looks like the information is correctly being pulled from the xml and added as a record to the store. I cannot; however, figure out how to make the record then populate my text field with any data. I have done quite a bit of digging in the forums already but nothing has seemed to work, I am sure there is something simple I am missing but I am not seeing it. My best guess is somehow the
testPanel.getForm().loadRecord(records[0]); is not sending the record to testPanel like I want it to. I really appreciate the help, this problem has been driving me crazy.:((



//called on html onclick event
function loadForm()
{
var store = new Ext.data.Store({
url:'test.xml',
autoLoad:true,
reader:new Ext.data.XmlReader({
record:'name',
success:'@success'
},
[{name:'first',mapping:'value'}]),
});

var testName = new Ext.form.TextField({
fieldLabel:'Name',
name:'name'
)};

var testPanel = new Ext.FormPanel({
frame:true,
store:store,
renderTo:'container',
items:[testName]
)};

store.on('load',function(store,records){
console.log(records[0]);
testPanel.getForm().loadRecord(records[0]);
});
}

Pilinir
24 May 2012, 5:24 AM
Wow, my name value in testName was incorrect no wonder it wasn't working, epic fail on my part! I need to drink more coffee....

scottmartin
24 May 2012, 12:14 PM
Thanks for the update.

Scott.