/* Always feel that the close button generated by TabPanel is too small
It's not easy to close, so I want to double-click the tab to make it easier.
So I found the following code on the Internet
url:http://atian25.iteye.com/blog/413920
But used in my system framework is not valid, I use the ExtJs4.1.
I don't know if it's my problem, but I can't find the wrong one.
So I thought of a way to pro-test support ExtJs4.1
It could be a bit of a hassle, but there's no way I can find the problem.
*///////////////////---Below is the method of online search I am invalid------////////////////////
[JavaScript]View Plaincopy
- var tabs = New Ext.tabpanel ({
- Renderto: ' tabs1 ',
- WIDTH:450,
- activetab:0,
- Frame:true,
- Defaults:{autoheight: true},
- items:[
- {contentel:' script ', title: ' Short Text '},
- {contentel:' markup ', title: ' Long Text '}
- ],
- Initevents: function () {
- Ext.TabPanel.superclass.initEvents.call (this);
- This.on (' Add ', this.onadd, this , {target: this });
- This.on (' Remove ', this.onremove, this , {target: this });
- This.mon (this.strip, ' MouseDown ', This.onstripmousedown, this );
- This.mon (this.strip, ' ContextMenu ', this.onstripcontextmenu, this );
- if (this.enabletabscroll) {
- This.mon (this.strip, ' MouseWheel ', This.onwheel, this );
- }
- //add:monitor title Dbclick
- This.mon (this.strip,' DblClick ',This.ontitledbclick, this);
- },
- //add:handler
- Ontitledbclick:function (e,target,o) {
- var t = this.findtargets (e);
- if (t.item.fireevent (' BeforeClose ', T.item)!== false) {
- T.item.fireevent (' close ', t.item);
- This.remove (T.item);
- }
- }
- });
-----Here is my method--------useful to Viewport only posted TabPanel code
[JavaScript]View Plaincopy < param name= "wmode" value= "Transparent" >
- {
- Xtype: "TabPanel",
- Region: "center",
- ID: "tabpanel",
- MINTABWIDTH:100,
- Listeners: {
- ' tabchange ': function () {
- }
- }
- }
I'm dynamically generating tab, so I'm going to write this down. Notice the code inside.
[JavaScript]View Plaincopy
- var createtab=function (id,title,url) {
- var tabs = ext.getcmp ("TabPanel");
- For (var i = 0; i < tabs.items.length; i++) {
- if (tabs.items.items[i].title = = title) {
- Tabs.items.items[i].show ();
- return;
- }
- }
- var newtabpanel= ext.create (' Ext.panel.Panel ', {
- Layout: ' fit ',
- Title:title,
- Collapsible: true,
- Closable:id==0? false:true,
- AutoScroll: false,
- Initevents: function () {
- var obj = this ;
- var id = ' tab-' + (this.id.split ('-') [1]-1 + 2) + '-btnwrap ';
- Ext.get (id). Dom.ondblclick = function () {
- if (obj.title!=' My Workbench ')
- Tabs.remove (obj);
- }
- },
- HTML: ' <iframe name= ' mainframe "width=" 100% "height=" 100% "frameborder=" 0 "src=" ' +url+' "></iframe > '
- });
- Tabs.add (Newtabpanel). Show ();
- }
[JavaScript]View Plaincopy < param name= "wmode" value= "Transparent" >
- Use the following code to test the Add tab
- Createtab ("0", "My Workbench", " myhome.htm");
- Createtab ("1", "account Management", " user.htm");
more 0
- Next Extjs4.1 checkboxgroup dynamic generate checkbox and checkbox-bound point-click event