1.申明控制参数
var progressBar = {};//显示窗体
var tcount = 0;
var count = 0; //计数器
var bartext = "";
var curnum = 0;
var beloaded = false; //是否加载成功
2.申明进度任务
var task = {
run : function() {
tcount++;
count = count + 5;
// 时间大于200秒
if (count >= 94) {
if (beloaded == false) {
count = count - 5;
}
}
if (count >= 100) {
progressBar.hide();
Ext.TaskMgr.stop(task); //做完停止任务,非常重要
count = 0; //清空计数器,及相关变量
bartext = "";
curnum = 0;
tcount = 0;
}
if (beloaded == true) {
count = 100;
}
curnum = count / 100;
bartext = curnum * 100 + "%";
progressBar.updateProgress(curnum, bartext);
},
interval : 500
};
3. 开始加载滚动条窗体
function SetProgressBar() {
tcount = 0;
count = 0;
bartext = "";
curnum = 0;
beloaded = false;
progressBar = Ext.Msg.show({
msg : "正在加载数据,请稍候...",
progress : true,
width : 300
});
Ext.TaskMgr.start(task);
}
4. 在数据加载结束的地方设置beloaded=true;控制task任务使之为100%,并隐藏滚动条窗体
log_treeloader.on('load', function(obj, node, response) {
beloaded = true;
if ((response.responseText.search('db_insert_error_j')) >= 0) {
alert(response.responseText);
}
count = 100;
});