PDA

View Full Version : Unable to populate grid data using asp.net web service



hemant1
27 May 2012, 10:05 PM
My Code

Store



var myStore = new Ext.data.JsonStore({
// Load data at once
autoLoad: true,
proxy: new Ext.data.HttpProxy({
type:'ajax',
url: 'http://localhost:1588/TestWebservice/WebServices/IncidentService.asmx/SelectIncidentList',
headers: {'Content-type': 'application/json'}
}),
root: 'd',
id: 'incidentid',
fields: ['incidentid','occured','headline','source','enteredby','bodyintro','webaddress','location1','location2','location3','location4','image','incidenttypeid','incidentsubtypeid']
});






var listView = Ext.create('Ext.grid.Panel', {
width:300,
height:h,
collapsible:true,
renderTo: Ext.getBody(),
store: myStore,
multiSelect: true,
viewConfig: {
emptyText: 'No images to display'
},


columns: [{
text: 'Incident List',
flex: 1,
dataIndex: 'headline'
}
]
});


listView.reconfigure(myStore);
listView.show();



my server return the json value like this



{"d":[{"incidentid":"22","occured":"2012-05-26T04:33:53-04:00","headline":"test1","source":"test","enteredby":"","bodyintro":"description","webaddress":"","location1":"29 -156.364","location2":"","location3":"","location4":"","image":"url of image","incidenttypeid":"0","incidentsubtypeid":"0"},{"incidentid":"23","occured":"2012-05-26T15:41:52-04:00","headline":"test2","source":"test2","enteredby":"","bodyintro":"description2","webaddress":"","location1":"27.75974 -82.67853","location2":"","location3":"","location4":"","image":"url of image","incidenttypeid":"","incidentsubtypeid":""}]}



but grid is not filled with the data

its shows only one blank row

thanks,

chramer
27 May 2012, 11:35 PM
Try this


var myStore = new Ext.data.JsonStore({
// Load data at once
autoLoad: true,
proxy: new Ext.data.HttpProxy({
type:'ajax',
url: 'http://localhost:1588/TestWebservice/WebServices/IncidentService.asmx/SelectIncidentList',
headers: {'Content-type': 'application/json'},
reader: {
type: 'json',
root: 'd'
},

}),
//root: 'd',
id: 'incidentid',
fields: ['incidentid','occured','headline','source','enteredby','bodyintro','webaddress','location1','location2','location3','location4','image','incidenttypeid','incidentsubtypeid']
});