如何将数据加载到使用 AJAX 向 ws 发送跨域请求的网格中?我可以发送请求,但是如何使用回调方法将数据加载到网格中?
在控制器文件中:
if(searchText){
var resultGrid = Ext.getCmp('myResultGrid');
store.setProxy({
type: 'ajax',
// cross domain request
url:"http://3.xxx.xxx.77/cs/sid/"+searchText,
actionMethods:{read:'GET'},
pageParam: false, //to remove param "page"
startParam: false, //to remove param "start"
limitParam: false,
timeout:9000000,
noCache : true,
reader: {
type: 'json'
}
});
resultGrid.store.load({
scope: this,
callback: function(records, operation, success)
{
var totalcount= 0;
totalcount = records.count(true);
if(totalcount > 0)
{
// Load the data into grid ???
}
else
{
Ext.Msg.alert("No Records found.");
}
}
});
}
存储文件:SearchResultsStore.js
Ext.define('AM.store.SearchResultsStore', {
extend: 'Ext.data.Store',
model: 'AM.model.SearchModel',
autoLoad: false
});
模型:
Ext.define('AM.model.SearchModel', {
extend: 'Ext.data.Model',
fields: ['slno', 'customer']
});
json响应
[{"slno": "12454","customer": "acd"}]
请帮助我卡住了!!!提前致谢