PDA

View Full Version : Bind JSON file value to Textbox



kirandasari
6 May 2009, 10:29 PM
How to bind the JSON file values to textbox?

Below is my JSON file content.

{ "rows":[
{
"id":"1",
"title":"Office Space",
"director":"Mike Judge",
"released":"1999-02-19"

}
]
}

I want to bind "ID" value to one Textbox.

Please help me.

666ragez666
6 May 2009, 10:37 PM
Hello,

Please see samples, forms related one should help you.

http://extjs.com/deploy/dev/examples/form/dynamic.html
http://extjs.com/deploy/dev/examples/form/xml-form.html

kirandasari
6 May 2009, 11:14 PM
Yes its helpful, but here the values are hardcoded like

xtype: 'textfield',
labelStyle: 'font: Times New Roman; width:125px',
fieldLabel: '*Account#',
name: 'Account #',
value: 'hi',
width:200


But for me the value can read from JSON file

Please help

kirandasari
7 May 2009, 12:44 AM
var store = new Ext.data.JsonStore({
url: 'Jsson.json',
root:'rows',
fields:
[
'id',
'title',
'director',
'released'
]
});

when i am using the below code

adhoc_form.getForm().findField('dollaramount').setValue(store.getAt(0).data.id);

I am getting the below error please help.

Microsoft JScript runtime error: 'getAt(...).data' is null or not an object

Animal
7 May 2009, 12:52 AM
Have you debugged?

kirandasari
7 May 2009, 1:01 AM
Please find the JPG file attached.

Animal
7 May 2009, 1:07 AM
So, when you poke into the Store and the Records, what do you find?

You can see wat your problem is and fix it by working on it.