PDA

View Full Version : Json objects in Combo Box



Jai123
27 Apr 2012, 3:29 AM
Hi,
I am new to ExtJs 4.I am using Json to populate combo box,as follows,

JSON:


{"Patient":[{"id":1,"emergencyPhone":"1234567890","primaryInsuranceId":{"id":1},"secondaryInsuranceId":{"id":2},"personalInfo":{"id":2,"firstName":"James","lastName":"Anderson","address":{"state":{"id":"2","stateName":"Alaska","code":"AK"},"zipcode":12345,"country":"USA","telephone":"1234567890","alternatePhone":"1234567890","faxNumber":"1234567890","email":"james@gmail.com"},"gender":"Male","dob":"2012-04-02","ssn":123456789,"race":"race"},"clearinghouseId":{"id":2,"name":"ALPHA Clearing House"},"provider":[]}]}



Ext.define('patientList', {
extend: 'Ext.data.Model',
fields: ['id','personalInfo']
});

var patient = Ext.create('Ext.data.Store', {
model: 'patientList',
autoLoad: true,
proxy: {
type: 'ajax',
url : url+'/lochweb/loch/patient/getAll',
reader: {
type: 'json',
root: 'Patient'
}
}
});

Combo Box

{
xtype:'combo',
fieldLabel: 'Patient',
name: "patientId",
id: "patientId",
queryMode:'local',
store: patient,
displayField: 'personalInfo.firstName',
valueField: 'id',
emptyText: "Select",
editable: false,
allowBlank:false
}


When i click the combo box,it shows firstname but after selecting that,it is not displaying in drop down.

skirtle
27 Apr 2012, 9:45 AM
Please post in the correct forum, I'll move this thread.

Please wrap any code you post in [CODE] tags.

I suspect your problem is your displayField. Try using a simple fieldname rather than a dotted-accessor. Move the dot notation into a mapping on the field definition in your model.

Jai123
29 Apr 2012, 7:36 PM
Hi Skirtle

I tried as u suggested but it didn't work.

skirtle
30 Apr 2012, 1:38 AM
Hi Skirtle

I tried as u suggested but it didn't work.

We'll need slightly more than 'it didn't work'. What happened?

Could you post the code your using with the corrections I suggested?