// 初始化一些变量
var aWeek = ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
var currentTime = new Ext.Toolbar.TextItem('当前时间:'
+ new Date().format('Y-m-d H:i:s') + ' '
+ aWeek[new Date().getDay()]);
// 定期更新时间
Ext.TaskMgr.start({
run : function() {
Ext.fly(currentTime.getEl()).update('当前时间:'
+ new Date().format('Y-m-d H:i:s') + ' '
+ aWeek[new Date().getDay()]);
},
interval : 1000
});
然后将currentTime放入到toolbar中即可,例如:
var north = new Ext.Panel({
region:"north",
// contentEl和autoHeight用来将top.html中图片嵌入到index.html中
contentEl:"topDiv",
autoHeight:true,
margins : "0 0 0 0",// 一个panel的上右左下的边距
border:false,
bbar: ["北京欢迎您",
'-',currentTime,
"->",{
text:"帮助",
icon:"images/help.png",
handler:sthHelp
},"-",{
text : "退出",
icon : "images/exit.png",
handler : function() {
window.location.href="../logout.action";
}
}, '-',' ']
});