Hybrid View
-
4 Oct 2012 10:45 PM #1
Unanswered: how to display jason data in textfield
Unanswered: how to display jason data in textfield
hi!
i am using following code to fetch data using JsonStore but unable to display it in textfield, although it is being displayed in drop down.
var prices = new Ext.data.JsonStore({
autoDestroy: true,
url: 'transport.php?controller=templates&action=getPrice&propid=' + recId,
root: 'prices',
id: 'propprice',
fields: ['propertyID','price']
});
and following for textfield in toolbar.
{
xtype: 'textfield',
name: 'textfield1',
id:'textfield1',
fieldLabel: 'Text field',
value: prices
}
it displays "[object Object]"in textfield, i have tried prices[0] and prices['price'] as well in this case nothing is displayed.
Can anyone please help me on this?
-
5 Oct 2012 3:08 AM #2Sencha - Community Support Team
- Join Date
- May 2012
- Location
- Istanbul
- Posts
- 1,331
- Vote Rating
- 76
- Answers
- 124
Hi Greg,
JsonStore return Store object, if root prices contain an array of item then you can fill text field by -var prices = new Ext.data.JsonStore({
})
Code:value = prices.data.items[0]
sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.
-
8 Oct 2012 5:29 AM #3
Thanks for help but issue is still there.I have tried this as well but nothing is displayed. When i use to write "value=prices.price[0]" the window in which this calculation is being performed, even window does not appear.
-
9 Oct 2012 10:40 PM #4Sencha - Community Support Team
- Join Date
- May 2012
- Location
- Istanbul
- Posts
- 1,331
- Vote Rating
- 76
- Answers
- 124
See this sample example-
for your form field try this -Code:var myStore = new Ext.data.JsonStore({ fields:['name', 'phone'], data:{'detail':[ { 'name': 'Lisa', "phone":"555-111-1224" }, { 'name': 'John', "phone":"500-111-1224" } ]}, proxy: { type: 'memory', reader:{ root:'detail' } } }); Ext.create('Ext.FormPanel', { width: 500, renderTo:Ext.getBody(), title: 'Panel', items: [{ xtype: 'textfield', fieldLabel: 'Name', value:myStore.data.items[0].data.name }] });
Code:value : prices.data.items[0].data.price
sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.
-
20 Oct 2012 2:48 AM #5
This can done if we have static data but i am fetching data from database.


Reply With Quote