在以下代码中,只有最后一项添加到col1和col2。
initializeCharts: function() {
var a = 0, col1Content = [], col2Content = [];
// initialize the default charts from constant config data
var col1 = this.getPerformanceOverviewpoolPanel().queryById('col1');
var col2 = this.getPerformanceOverviewpoolPanel().queryById('col2');
for(a = 0;a < DefaultMetrics.DEFAULT_METRICS.length;a++) {
var chart = Ext.create('com.atlas.view.portlet.GraphiteChartPortlet', DefaultMetrics.DEFAULT_METRICS[a]);
chart.title = DefaultMetrics.DEFAULT_METRICS[a].chartTitle;
if(a % 2) {
col2Content.push(chart);
} else {
col1Content.push(chart);
}
}
col1.add(col1Content);
col2.add(col2Content);
},