ext2.2 怎么访问到panel
Ext.namespace('ExtFrame.ui');
ExtFrame.ui.ChatWin = function(_toUserName, _currentUser) {
var toUserName = _toUserName;
var currentUser = _currentUser;
var win = null;
/**
* @method creteWin
* @public
* @description create the ChatWin
*/
var createWin = function() {
win = new Ext.Window({
title : '和' + toUserName + '交流中',
id : toUserName,
width : 550,
height : 450,
collapsible : true,
labelAlign : 'left',
labelWidth : 60,
hideLabel : false,
maximizable : true,
border : false,
layout : 'border',
frame : true,
items : [{
region : 'north',
border : 0,
height : 250,
xtype : 'panel',
id : 'showMsg',
layout : 'fit',
bodyStyle : 'padding:10px;'
},
{
region : 'center',
border : 0,
height : 20,
xtype : 'toolbar',
id : 'test',
layout : 'fit',
bodyStyle : 'padding:10px;',
items :[ { xtype:'tbbutton', text:'查看聊天记录' ,
handler:function() {
addhistory(_toUserName, _currentUser);
}
},
' ',
{ xtype:'tbbutton', text:'发送文件' ,
handler:function() {
alert('该功能未开放'); }
} ]
},
{
region : 'south',
minHeight : 150,
split : true,
xtype : 'form',
layout:'fit',
border : false,
hideLabels : true,
bodyStyle : 'background:transparent;',
height : 150,
items : [
{
xtype : 'htmleditor',
id : 'editMsg',
fieldLabel : '',
name : 'body',
height:130,
allowBlank : false,
anchor : '0-50',
border : false
}],
buttons : [{
text : '发送',
handler : viewMsg
}, {
text : '关闭',
handler : closeWin
}]
}]
});
win.show();
}
/**
* @method sendMsg
* @private
* @description 查看你的聊天记录
*/
var addhistory =function(_toUserName, _currentUser) {
var sl = this.ownerCt.ownerCt.getComponent(0);
///这里出问题访问不到
alert(this.ownerCt.ownerCt.getComponent(0));
sl.body.insertHtml("beforeEnd", "ddddd");
sl.body.scroll('bottom', 9999);
}
/**
* @method sendMsg
* @private
* @description view your messages dynamicly
*/
var viewMsg = function() {
var message = this.ownerCt.form.items.items[0].getValue();
var sendDate = new Date().format('Y-m-d H:i:s');
var showPanel = this.ownerCt.ownerCt.getComponent(0);
//这里可以访问 alert(this.ownerCt.ownerCt.getComponent(0));
var formatMsg = "<div class='_msgtitle' style='color:blue'>"
+ currentUser + " " + sendDate + "</div><div class='_msg'>"
+ message + "</div>";
showPanel.body.insertHtml("beforeEnd", formatMsg);
showPanel.body.scroll('bottom', 9999);
this.ownerCt.form.items.items[0].reset();
submitMsg(message);
}
/**
* @method closeWin
* @private
* @description close the chatWin
*/
var closeWin = function() {
Ext.getCmp(toUserName).close();
}
/**
* @method submitMsg
* @param message
* @private
* @description submit the messages to the server
*/
var submitMsg = function(message) {
var conn = new Ext.data.Connection();
conn.request({
url : 'http://localhost:8080/reseller/sendMsg.do',
method : 'POST',
params : {
fromUserName : currentUser,
toUserName : toUserName,
message : message
},
sucess : function(responseObject) {
},
failure : function() {
Ext.Msg.alert('发送失败', responseObject.statusText);
}
});
}
return {
/**
* @method init
* @public
* @description initializes the win
*/
init : function() {
if (!win) {
createWin();
} else
win.show();
}
}
}
问下 items :[ { xtype:'tbbutton', text:'查看聊天记录' , 中的tbbutton 怎么访问到showMsg
用了 this.ownerCt.ownerCt.getComponent(0);不行
用了 ext.getcmp 也不行
用了 Ext.getCmp(msg.fromUserName).findById("showMsg") 也没找到