PDA

View Full Version : [CLOSED] TabCloseMenu Plugin.



CanopiusApplications
Dec 11, 2013, 1:19 PM
Guys

Anyway I have a series of tabs which have the property "CloseAction=Hide" however if I close them using the TabCloseMenu plugin they seem to get destroyed as opposed to hidden.

Is there a way to tell the TabCloseMenu plugin to respect that property or to override the default handler of the TabCloseMenu.

Example of code that fails.




<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Debug.aspx.cs" Inherits="Measures.Debug" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
[DirectMethod]
public void OpenTab(bool Tab1Open, bool Tab2Open)
{
if (Tab1Open == false)
{
this.TabPanel1.ShowTab(this.Tab1, true);
this.Tab1.SetTitle("Tab 1");
}

else if (Tab2Open == false)
{
this.TabPanel1.ShowTab(this.Tab2, true);
this.Tab2.SetTitle("Tab 2");
}
}
</script>

<!DOCTYPE html>

<html>
<head id="Head1" runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form id="Form2" runat="server">
<ext:ResourceManager ID="ResourceManager2" runat="server" />

<ext:Button ID="Button2"
runat="server"
Text="OpenTab"
OnClientClick="App.direct.OpenTab(App.TabPanel1.contains(App.Tab1 ), App.TabPanel1.contains(App.Tab2));" />

<ext:TabPanel ID="TabPanel1" runat="server">

<Plugins>
<ext:TabCloseMenu ID="TabCloseMenu1" runat="server" />
</Plugins>

<Bin>
<ext:Panel
ID="Tab1"
runat="server"
Closable="true"
CloseAction="Hide"
Hidden="true" />

<ext:Panel
ID="Tab2"
runat="server"
Closable="true"
CloseAction="Hide"
Hidden="true" />
</Bin>
</ext:TabPanel>
</form>
</body>
</html>

Daniil
Dec 11, 2013, 2:23 PM
Hi @CanopiusApplications,

I think it is a defect. The TabCloseMenu should respect a tab's CloseAction setting.

Please try this override:

Ext.tab.TabCloseMenu.override({
onClose : function() {
this.tabPanel.closeTab(this.item); // instead of this.tabPanel.remove(this.item);
},

doClose : function(excludeActive){
var items = [];

this.tabPanel.items.each(function(item){
if(item.closable){
if(!excludeActive || item != this.item){
items.push(item);
}
}
}, this);

Ext.each(items, function(item){
this.tabPanel.closeTab(item); // instead of this.tabPanel.remove(item);
}, this);
}
});

CanopiusApplications
Dec 11, 2013, 4:08 PM
Perfect thanks Danil.

D

Daniil
Dec 12, 2013, 7:19 AM
Committed to the SVN trunk in the revision #5555.

Thank you again for the report!