简体   繁体   中英

extjs setValue for textfield not working with objects

Quite new to extjs. When I set the value of a textfield with a constant value it works fine. but how can I get the contents of obj as seen here.

This is my json file

{ success :true, data :{ event_id:'1',event_type:'we',szdate:'0000-00-00',szvenue:'ww',population:'233',rsvp_name:'Amma Baffoe',rsvp_cont:'222' , event_id:'2',event_type:'',szdate:'0000-00-00',szvenue:'',population:'0',rsvp_name:'Serwaa',rsvp_cont:'' }}

This is my code

      obj = Ext.JSON.decode(action.responseText);
      Ext.getCmp('population').setValue("I am here"); // works fine
      Ext.getCmp('population').setValue(obj.variable); //how do I get the variable 'szdate'?

Like this:

Ext.getCmp('population').setValue(obj.data.szdate); 

Or if you've got the szdate value in a varibale, Like this:

var varibale = 'szdate';
Ext.getCmp('population').setValue(obj.data[varibale]); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM