導航:首頁 > 編程語言 > extjstabpanel切換事件

extjstabpanel切換事件

發布時間:2023-03-06 21:57:13

A. 在Extjs中,我想通過點擊一個按鈕,然後在一個TabPanel中加入一個Panel組件,請問怎麼做

var centerPanel = Ext.create('Ext.TabPanel', {
region: 'center',
deferredRender: false,
activeTab: 0,
items: []
})
var ftab = Ext.create('Ext.Panel', {
tpl: new Ext.XTemplate('<iframe style="width: 100%; height: 100%; border: 0;padding:4px 4px 4px 4px;" src="{url}"></iframe>'),
load: function (b) { this.update(this.tpl.apply(b)) }, clear: function () { this.update("") },
title: '首頁',
autoScroll: true
});
ftab.load({ url: '<%=Url.Action("Welcome",new{ controller="Home"}) %>' });
centerPanel.add(ftab);
function trsel(view, record, item, index, e) {
if (record.raw.leaf) {
var tab = centerPanel.getComponent("tab" + record.raw.id); //獲取tab對象
if (!tab) {//如果tab不存在,就創建並添加到中
tab = Ext.create('Ext.Panel', {
tpl: new Ext.XTemplate('<iframe style="width: 100%; height: 100%; border: 0;padding:4px 4px 4px 4px;" src="{url}"></iframe>'),
load: function (b) { this.update(this.tpl.apply(b)) }, clear: function () { this.update("") },
id: "tab" + record.raw.id,
title: record.raw.text,
closable: true,
autoScroll: true
});
tab.load({ url: '/' + record.raw.menu_area + '/' + record.raw.menu_controller + '/' + record.raw.menu_action });
centerPanel.add(tab);
}
centerPanel.setActiveTab(tab); //設置顯示當前面板
}
};
函數是點擊菜單樹時調用的。你自己調整一下,點按鈕時調這個函數就可以。不過網上說用iframe不好,我也想看看有沒有其他的方法

B. extjs的panel組件怎麼使用

//html代碼
<div id="container">
</div>

//js代碼
var p = new Ext.Panel({
title: 'My Panel',//標題
collapsible:true,//右上角上的那個收縮按鈕,設為false則不顯示
renderTo: 'container',//這個panel顯示在html中id為container的層中
width:400,
height:200,
html: "<p>我是內容,我包含的html可以被執行!</p>"//panel主體中的內容,可以執行html代碼
});

因為panel組件的子類組件包括TabPanel,GridPanel,FormPanel,TreePanel組件,所以非常有必要介紹Panel組件的配置參數和相關的屬性、方法。

//配置參數(只列舉部分常用參數)
1.autoLoad:有效的url字元串,把那個url中的body中的數據載入顯示,但是可能沒有樣式和js控制,只是html數據
2.autoScroll:設為true則內容溢出的時候產生滾動條,默認為false
3.autoShow:設為true顯示設為"x-hidden"的元素,很有必要,默認為false

4.bbar:底部條,顯示在主體內,//代碼:bbar:[{text:'底部工具欄bottomToolbar'}],
5.tbar:頂部條,顯示在主體內,//代碼:tbar:[{text:'頂部工具欄topToolbar'}],
6.buttons:按鈕集合,自動添加到footer中(footer參數,顯示在主體外)//代碼:buttons:[{text:"按鈕位於footer"}]
7.buttonAlign:footer中按鈕的位置,枚舉值為:"left","right","center",默認為right

8.collapsible:設為true,顯示右上角的收縮按鈕,默認為false
9.draggable:true則可拖動,但需要你提供操作過程,默認為false

10.html:主體的內容
11.id:id值,通過id可以找到這個組件,建議一般加上這個id值
12.width:寬度
13.height:高度
13.title:標題

14.titleCollapse:設為true,則點擊標題欄的任何地方都能收縮,默認為false.

15.applyTo:(id)呈現在哪個html元素裡面
16.contentEl:(id)呈現哪個html元素裡面,把el內的內容呈現
17.renderTo:(id)呈現在哪個html元素裡面
//關於這三個參數的區別(個人認為:applyTo和RenderTo強調to到html元素中,contentEl則是html元素到ext組件中去):
英文如下(本人英語poor,不敢亂翻譯):
contentEl - This config option is used to take existing content and place it in the body of a new panel. It is not going to be the actual panel itself. (It will actually the innerHTML of the el and use it for the body). You should add either the x-hidden or the x-hide-display CSS class to prevent a brief flicker of the content before it is rendered to the panel.
applyTo - This config option allows you to use pre-defined markup to create an entire Panel. By entire, I mean you can include the header, tbar, body, footer, etc. These elements must be in the correct order/hierarchy. Any components which are not found and need to be created will be autogenerated.
renderTo - This config option allows you to render a Panel as its created. This would be the same as saying myPanel.render(ELEMENT_TO_RENDER_TO);
哪位大人幫忙翻譯下...
考慮到入門,方法事件會在以後的文章中以實例穿插。
1.可拖動的panel實例
下面我們做個可拖動panel例子來熟悉下panel這個最基本的組件.

//html代碼
..無..

//下面創建一個允許拖動的panel,但是拖動的結果不能保存
var p=new Ext.Panel({
title: 'Drag me',
x: 100,
y: 100,
renderTo: Ext.getBody(),//x,y,renderTo:Ext.getBody()初始化panel的位置
floating: true,//true
frame: true,//圓角邊框
width: 400,
height: 200,
draggable:true
}).show();//在這里也可以不show()
但是還不能拖到其他的地方,我們需要改寫draggable:

draggable: {
insertProxy: false,//拖動時不虛線顯示原始位置

onDrag : function(e){
var pel = this.proxy.getEl();
this.x = pel.getLeft(true);
this.y = pel.getTop(true);//獲取拖動時panel的坐標
},
endDrag :

function(e){
this.panel.setPosition(this.x, this.y);//移動到最終位置
}
}
實現了可保存的拖動

拖動的時候陰影還在原位置,我們再在draggable中的onDrag事件中添加代碼:

var s = this.panel.getEl().shadow;
if (s) {
s.realign(this.x, this.y, pel.getWidth(), pel.getHeight());
}
//shadow的realign方法的四個參數,改變shadow的位置大小屬性
最後這個可拖動的panel的代碼為:

var p=new Ext.Panel({
title: 'Drag me',
x: 100,
y: 100,
renderTo: Ext.getBody(),
floating: true,
frame: true,
width: 400,
height: 200,
draggable: {
insertProxy: false,
onDrag :

function(e){
var pel = this.proxy.getEl();
this.x = pel.getLeft(true);
this.y = pel.getTop(true);

var s = this.panel.getEl().shadow;
if (s) {
s.realign(this.x, this.y, pel.getWidth(), pel.getHeight());
}
},
endDrag : function(e){
this.panel.setPosition(this.x, this.y);
}
}
})
//效果圖片我就不貼出來了
2.帶頂部,底部,腳部工具欄的panel

var p=new Ext.Panel({
id:"panel1",
title:"標題",
collapsible:true,
renderTo:"container",
closable:true,
width:400,
height:300,
tbar:[{text:"按鈕1"},{text:"按鈕2"}], //頂部工具欄
bbar:[{text:"按鈕1"},{text:"按鈕2"}], //底部工具欄
html:"內容",
buttons:[{text:"按鈕1"},{text:"按鈕2"}] //footer部工具欄
});

我們已經在各種工具欄上添加了按鈕,但是卻沒有激發事件,下面我們來添加按鈕事件代碼:

tbar:[{text:"按鈕1",handler:function(){Ext.MessageBox.alert("我是按鈕1","我是通過按鈕1激發出來的彈出框!")}},{text:"按鈕2"}],
//改寫tbar,添加handler句柄,點擊頂部工具欄上按鈕1,彈出提示框,效果圖大家想像下,就不貼出來了
當然,一般情況下,我們只要一個工具欄,這里只是為了演示!
3.panel工具欄

//添加下面的代碼到panel配置參數中
tools:[{id:"save"},{id:"help"},{id:"up"},{id:"close",handler:function(){Ext.MessageBox.alert("工具欄按鈕","工具欄上的關閉按鈕時間被激發了")}}],
//id控制按鈕,handler控制相應的事件
//id的枚舉值為:
toggle (collapsable為true時的默認值)
close
minimize
maximize
restore
gear
pin
unpin
right
left
up
down
refresh
minus
plus
help
search
save
print

C. 使用extjs3.4版本,TabPanel中嵌套的是iframe,當A tab和B tab 切換時會報 NS_ERROR_FAILURE。

尊敬的用戶,您好!很高興為您答疑。
這個錯誤一般出現在表單回提交過程中,而您答提到了您利用了多框架,故而推測您這是在瀏覽器中出現了跨域提交導致的問題。
希望我的回答對您有所幫助,如有疑問,歡迎繼續咨詢我們。

D. extjs3.2 tabpanel右鍵菜單事件總是報錯TypeError: e.getXY is not a function

function onContextMenu(ts, item, e) {
menu.showAt(e.getPoint());
}
這樣試試呢

E. 如何在extjs中打開一個新的界面,原先的界面還存在。

添加單擊事件就可以了
listeners : {
'click' : tree_itemclick
}
-------------------------------------
function tree_itemclick (node, event) {
var tabId = "tab-" + node.id;
var tabTitle = node.text;
var tabLink = node.attributes.url;
//alert(tabLink);
currentPage = tabId;
var centerPanel = Ext.getCmp("mainpanel");
var tab = centerPanel.getComponent(tabId);

var subMainId = "tab-" + node.id + "-main";
if (!node.isLeaf()){
// 為葉子節點時,點擊進入鏈接
event.stopEvent();
return;
}
if (!tab) { //判斷MainTabPanel中是否存在這個頁面,如果不存在將創建一個

tab = centerPanel
.add(new Ext.Panel(
{
id : tabId,
title : tabTitle,
autoScroll : true,
iconCls : "tabIconCss",
layout : "fit", //填充布局,它不會讓load進來的東西改變大小
border : false,
closable : true,
//closeAction : 'hide',
items : [ {
showMask : true,
maskMsg : '正在載入數據,請稍等...',
scripts : true,
html : "<iframe scrolling='auto' frameborder='0' width='100%' height='100%' src='"
+ tabLink + "'> </iframe>"
} ]
}));

}else {
centerpanel.setActiveTab(tab);
}

centerPanel.setActiveTab(tab); //將焦點指向我點擊節點打開的頁面

};

F. extjs怎麼設置tabpanel詳解

Ext.onReady(function(){
vari=4;
//注意:每個Tab標簽只渲染一次
vartabs=newExt.TabPanel({
renderTo:Ext.getBody(),//綁定在body標簽上
activeTab:0,//初始顯示第幾個Tab頁
deferredRender:false,//是否在顯示每個標簽的時候再渲染標簽中的內容.默認true
tabPosition:'top',//表示TabPanel頭顯示的位置,只有兩個值top和bottom.默認是top.
enableTabScroll:true,//當Tab標簽過多時,出現滾動條
items:[{//Tab的個數
title:'Tab1',
html:'Asimpletab',
listeners:{render:function(){//為每個Tab標簽添加監聽器.當標簽渲染時觸發
Ext.Msg.alert("Tab1","渲染Tab1成功");
}}
},{
title:'Tab2',
html:'Anotherone',
listeners:{render:myRender}
},{
title:'Tab3',
autoLoad:'test.html',
closable:true,
listeners:{render:myRender}
}],
bbar:[{//添加一個底部工具欄,並且在該工具欄上添加兩個按鈕
text:'添加標簽',
handler:function(){//添按鈕被點擊時觸發這個匿名函數(注意:該屬性在button中能查到).
varid=i;
tabs.add({//添加一個Tab標簽
id:id,
title:'Tab'+i,
closable:true
});
i=i+1;
tabs.setActiveTab(id);//當id為"id"的Tab標簽顯示(變為活動標簽).
}
},{
text:'刪除標簽',
handler:function(){
vart=tabs.getActiveTab();//獲得當前活動標簽的引用
if(t.closable){
tabs.remove(t);//刪除標簽
}else{
Ext.Msg.alert("提示","該標簽不能關閉");
}
}
}]
});

//把TabPanel組件充滿整個body容器.
newExt.Viewport({
layout:'fit',
items:tabs
});
});

G. extjs 如何在tab標簽上添加click事件要能夠點擊一下標簽實現查詢後台資料庫數據的

var tabs = Ext.createWidget('tabpanel', {
region : 'center',
activeTab : 0,
width : document.body.clientWidth,
height : document.body.clientHeight - 50,
defaults : {
bodyPadding : 10
},
items : [ Panel1, Panel2,Panel3
],
listeners : {
'tabchange' : function(tab, newc, oldc) {
//獲取你點擊的tab頁 完成你的操作 這個是4.0的
}
}
});

閱讀全文

與extjstabpanel切換事件相關的資料

熱點內容
大數據與工業的結合包括哪些領域 瀏覽:993
蘋果7鬧鍾鈴聲設置歌曲 瀏覽:168
法庭文件有哪些 瀏覽:211
zip文件怎麼刪除嗎 瀏覽:247
win1016179安裝失敗 瀏覽:457
pp助手的文件系統 瀏覽:218
設計網站橫幅廣告要哪些因素 瀏覽:991
勞務報酬認定在多少號文件 瀏覽:209
本地數據傳輸業務有什麼用途 瀏覽:375
什麼情侶app好用 瀏覽:575
旅遊攻略適合下什麼app 瀏覽:403
nodejsbusboy下載 瀏覽:106
同事不會送文件找不到地方 瀏覽:473
銀聯萬事達applepay 瀏覽:834
試玩怎麼推廣app 瀏覽:588
課設報告中數據結構寫什麼東西 瀏覽:44
男生怎麼搜到網站的 瀏覽:441
當前無網路怎麼解決 瀏覽:299
x200thinkpad升級 瀏覽:568
華為mate8幾個版本的區別 瀏覽:582

友情鏈接