ext实现ajax调用接口加数据到grilpanel
2012-06-17 11:47
274 查看
ds = new Ext.data.SimpleStore({
fields : [
{
name : 'city'
}, {
name : 'district'
}, {
name : 'deviceId'
}, {
name : 'alias'
},{
name : 'usercount'
}, {
name : 'down'
}, {
name : 'glys'
}
]});
cm = new Ext.grid.ColumnModel([{
header : formGridField("地市"),
width : MaxWidth/4,
sortable : true,
dataIndex : 'city'
},{
header : formGridField("区县"),
width : MaxWidth/4,
sortable : true,
dataIndex : 'district'
},{
header : formGridField("热点名称"),
width : MaxWidth/4,
sortable : true,
dataIndex : 'deviceId'
},{
header : formGridField("关联失败率"),
width : MaxWidth/4,
sortable : true,
dataIndex : 'alias'
},{
header : formGridField("关联用户数"),
width : MaxWidth/4,
sortable : true,
dataIndex : 'usercount'
},{
header : formGridField("下行信号强度"),
width : MaxWidth/4,
sortable : true,
dataIndex : 'down'
},{
header : formGridField("关联拥塞率"),
width : MaxWidth/4,
sortable : true,
dataIndex : 'glys'
}
]);
centerGridPanel= new Ext.grid.GridPanel({
id : "ClientGrid",
xtype : "grid",
//autoHeight:"auto",
bodyStyle : transparent,
//enableColumnHide : true,
stripeRows: true,
border : false,
autoscoll:true,
loadMask:true,
height:500,
viewConfig: { forceFit:true,scrollOffset:0 },
// tbar: new Ext.Toolbar({
// items: [
// {
// text:'趋势分析',
// handler: function(){
//
// }
// },
// {
// text:'环比分析',
// handler: function(){
//
// }
// }
// ]
// }),
cm:cm,
ds:ds,
loadMask : ({
msg : "数据加载中..."
})
//bbar : pageBar
});
centerGridPanel.on('render',function(centerGridPanel,rowIdx,e){
getResouses(url);
})
function getResouses(url){
var result;
//var city = encodeURIComponent('杭州');
//alert(city);
var mk = new Ext.LoadMask(Ext.getCmp('northGridPanel').getEl(), {
msg : '数据加载中...',
removeMask : true
});
mk.show();
Ext.Ajax.request({
disableCaching : true,
url : url,
success : function(date) {
if (date.responseText != "") {
var mk = new Ext.LoadMask(Ext.getCmp('northGridPanel').getEl(), {
msg : '数据加载中...',
removeMask : true
});
mk.show();
result = Ext.util.JSON.decode(date.responseText);
var dateArray = [];
for(var i=0;i<result.length;i++){
//alert(result[i].hotspot.city);
dateArray.push([
result[i].hotspot.city,
result[i].hotspot.district,
result[i].hotspot.location,
result[i].assoKpiData.assoFailureRatio,
result[i].assoUserCount,
result[i].downSignalStrength,
result[i].assoKpiData.assoJamRatio
]);
}
Ext.getCmp('ClientGrid').getStore().loadData(dateArray);
}
mk.hide();
},
failure : function(date) {
mk.hide();
},
headers : {'Accept':'application/json'},
params : {},
method : 'get'
});
}
fields : [
{
name : 'city'
}, {
name : 'district'
}, {
name : 'deviceId'
}, {
name : 'alias'
},{
name : 'usercount'
}, {
name : 'down'
}, {
name : 'glys'
}
]});
cm = new Ext.grid.ColumnModel([{
header : formGridField("地市"),
width : MaxWidth/4,
sortable : true,
dataIndex : 'city'
},{
header : formGridField("区县"),
width : MaxWidth/4,
sortable : true,
dataIndex : 'district'
},{
header : formGridField("热点名称"),
width : MaxWidth/4,
sortable : true,
dataIndex : 'deviceId'
},{
header : formGridField("关联失败率"),
width : MaxWidth/4,
sortable : true,
dataIndex : 'alias'
},{
header : formGridField("关联用户数"),
width : MaxWidth/4,
sortable : true,
dataIndex : 'usercount'
},{
header : formGridField("下行信号强度"),
width : MaxWidth/4,
sortable : true,
dataIndex : 'down'
},{
header : formGridField("关联拥塞率"),
width : MaxWidth/4,
sortable : true,
dataIndex : 'glys'
}
]);
centerGridPanel= new Ext.grid.GridPanel({
id : "ClientGrid",
xtype : "grid",
//autoHeight:"auto",
bodyStyle : transparent,
//enableColumnHide : true,
stripeRows: true,
border : false,
autoscoll:true,
loadMask:true,
height:500,
viewConfig: { forceFit:true,scrollOffset:0 },
// tbar: new Ext.Toolbar({
// items: [
// {
// text:'趋势分析',
// handler: function(){
//
// }
// },
// {
// text:'环比分析',
// handler: function(){
//
// }
// }
// ]
// }),
cm:cm,
ds:ds,
loadMask : ({
msg : "数据加载中..."
})
//bbar : pageBar
});
centerGridPanel.on('render',function(centerGridPanel,rowIdx,e){
getResouses(url);
})
function getResouses(url){
var result;
//var city = encodeURIComponent('杭州');
//alert(city);
var mk = new Ext.LoadMask(Ext.getCmp('northGridPanel').getEl(), {
msg : '数据加载中...',
removeMask : true
});
mk.show();
Ext.Ajax.request({
disableCaching : true,
url : url,
success : function(date) {
if (date.responseText != "") {
var mk = new Ext.LoadMask(Ext.getCmp('northGridPanel').getEl(), {
msg : '数据加载中...',
removeMask : true
});
mk.show();
result = Ext.util.JSON.decode(date.responseText);
var dateArray = [];
for(var i=0;i<result.length;i++){
//alert(result[i].hotspot.city);
dateArray.push([
result[i].hotspot.city,
result[i].hotspot.district,
result[i].hotspot.location,
result[i].assoKpiData.assoFailureRatio,
result[i].assoUserCount,
result[i].downSignalStrength,
result[i].assoKpiData.assoJamRatio
]);
}
Ext.getCmp('ClientGrid').getStore().loadData(dateArray);
}
mk.hide();
},
failure : function(date) {
mk.hide();
},
headers : {'Accept':'application/json'},
params : {},
method : 'get'
});
}
相关文章推荐
- ajax调用geoServer rest接口实现数据发布
- asp.net ajax客户端编程+jquery:实现泛型数据的客户端数据调用、添加、删除
- thinkjs学习-this.assign传递数据和ajax调用后台接口
- 阿里天气数据接口调用实现(Java和JS)
- Winform实现调用asp.net数据接口实例
- 【CI学习笔记】利用jquery中的ajax,调用接口,实现登录
- MVC4中AJAX Html页面打开调用后台方法实现动态加载数据库中的数据
- ajax调用返回php接口返回json数据
- HTML5网页通过ajax跨域调用接口获取json数据并解析(一)
- jsp代理实现ajax跨域调用获取数据
- ajax 数据交互 接口调用
- Ajax调用restful接口传送Json格式数据的方法
- ExtJS中FormPanel实现数据加载和提交 - EXT - AJAX - JavaEye论坛
- jquery中用$.ajax实现注册(html、jquery、php、接口文档)、ajax验证用户提交数据
- 通过ajax调用HttpServlet来实现前后端数据交互
- ajax传送json格式数据,调用restful接口
- js 调用ajax方法实现新增数据,原页面刷新
- .net之Ajax获取接口数据并实现循环播放
- ajax跨域实现api 接口调用
- Spring 过滤器、分发器结合实现 只对某种类型数据 在 Ajax调用时候 进行过滤