對於Ext(版本2.2.1),我們使用下面的覆蓋來獲得我們指定的id,而不是Ext生成的任何內容。不知道我們在哪裏找到它,可能是Ext論壇。
Ext.override(Ext.Button, {
initButtonEl : function(btn, btnEl){
this.el = btn;
btn.addClass("x-btn");
if(this.id){
//this.el.dom.id = this.el.id = this.id;
// override
btnEl.dom.id = btnEl.id = this.id;
// end override
}
if(this.icon){
btnEl.setStyle('background-image', 'url(' +this.icon +')');
}
if(this.iconCls){
btnEl.addClass(this.iconCls);
if(!this.cls){
btn.addClass(this.text ? 'x-btn-text-icon' : 'x-btn-icon');
}
}
if(this.tabIndex !== undefined){
btnEl.dom.tabIndex = this.tabIndex;
}
if(this.tooltip){
if(typeof this.tooltip == 'object'){
Ext.QuickTips.register(Ext.apply({
target: btnEl.id
}, this.tooltip));
} else {
btnEl.dom[this.tooltipType] = this.tooltip;
}
}
if(this.pressed){
this.el.addClass("x-btn-pressed");
}
if(this.handleMouseEvents){
btn.on("mouseover", this.onMouseOver, this);
// new functionality for monitoring on the document level
//btn.on("mouseout", this.onMouseOut, this);
btn.on("mousedown", this.onMouseDown, this);
}
if(this.menu){
this.menu.on("show", this.onMenuShow, this);
this.menu.on("hide", this.onMenuHide, this);
}
if(this.repeat){
var repeater = new Ext.util.ClickRepeater(btn,
typeof this.repeat == "object" ? this.repeat : {}
);
repeater.on("click", this.onClick, this);
}
btn.on(this.clickEvent, this.onClick, this);
}
});
Ext.override(Ext.menu.Item, {
onRender : function(container, position){
var el = document.createElement("a");
el.hideFocus = true;
el.unselectable = "on";
el.href = this.href || "#";
if(this.hrefTarget){
el.target = this.hrefTarget;
}
el.className = this.itemCls + (this.menu ? " x-menu-item-arrow" : "") + (this.cls ? " " + this.cls : "");
// override
if (this.id){
el.id = this.id;
}
// end override
el.innerHTML = String.format(
'<img src="{0}" class="x-menu-item-icon {2}" />{1}',
this.icon || Ext.BLANK_IMAGE_URL, this.itemText||this.text, this.iconCls || '');
this.el = el;
Ext.menu.Item.superclass.onRender.call(this, container, position);
}
});
更改URL部分不是寫的選擇,因爲可能有100個屏幕這意味着很多工作手冊..所以,如果這個解決方案採用有在自動化測試是沒有意義的。因爲我們可以做手動測試... 應該有一些其他簡單的工作...如果我得到的答案,我肯定會在這裏發佈.... – 2010-08-07 08:13:26