日期:2014-05-16 浏览次数:20349 次
/**
* 统计分析-河流流量统计(水文) 控制器
*/
Ext.define('MyApp.controller.statAnalysis.hydrology.FlowStatCtrl', {
extend : 'Ext.app.Controller',
requires : [],
stores : ['statAnalysis.hydrology.FlowStatStore','statAnalysis.hydrology.FlowStatComboStore'],
models : [],
views : ['statAnalysis.hydrology.container.FlowStatPanel','statAnalysis.hydrology.grid.FlowStatGrid',
'statAnalysis.hydrology.container.FlowStatChartPanel','component.HighChartView','component.MonthField',
'statAnalysis.hydrology.entry.FlowStatEntry'
],
refs : [{
ref : 'highchartview',
selector : 'flowstatentry highchartview'
}, {
ref : 'flowstatchartpanel',
selector : 'flowstatentry flowstatchartpanel'
}, {
ref : 'flowstatpanel',
selector : 'flowstatentry flowstatpanel'
}, {
ref : 'flowstatgrid',
selector : 'flowstatentry flowstatgrid'
}],
init : function() {
this.control({
'flowstatentry flowstatchartpanel combobox' : {
select : this.loadData
},//加载图表时第一次加载数据
'flowstatentry highchartview':{
afterrender:this.highchartviewFirstLoad
},
'flowstatentry flowstatpanel button[action=search]' :{
click : this.searchFlowStatData
},
'flowstatentry':{
close:this.onCloseTab
}
});
},
/**
* 关闭tab,清空数据
*/
onCloseTab:function(){
//取得grid中的store
var grid=this.getFlowstatgrid();
var store=grid.store;
//加载新数据之前清空
store.removeAll();
//给年份下拉框赋值
var combo = this.getFlowstatchartpanel().down('combobox[name=NF]');
var comboYF =this.getFlowstatchartpanel().down('combobox[name=YF]');
//清空时间数据
combo.store.removeAll();
comboYF.store.removeAll();
},
/**
* 年份和月份的combobox,select事件
*
*/
loadData:function(combo, records, eOpts){
var year = this.getFlowstatchartpanel().down('combobox[name=NF]').value;
var month = this.getFlowstatchartpanel().down('combobox[name=YF]').value;;
//通过年份得到store
var store=this.getStore('statAnalysis.hydrology.FlowStatStore');
//取得固定年份的值
var arr=store.query("NF", year);
var records=arr.items;
var arrData = [];
for(index in records){
if(records[index].get('YF')==month){
arrData.push(records[index])
}
}
//过滤后records,作为数据源给图表
getCtrl('statAnalysis.hydrology.FlowStatCtrl').loadDataToChart('月河流流量',year+'年'+month+'月',arrData);
},
/**
* chart数据加载
* @param title 标题(固定)
* @param subTitle 子标题(年份)
* @param store 数据
*/
loadDataToChart:function(title,subTitle,arrData){
var highchartview=this.getHighchar