PDA

View Full Version : [CLOSED] Error when binding KeyMap to not active Panel in TabPanel



Fredrik
Apr 02, 2012, 10:06 AM
I get an error with the following code. The problem seems to be that you can't bind a KeyMap to a not active Panel in a TabPanel.



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


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Viewport ID="Viewport1" runat="server" Layout="VBoxLayout">
<LayoutConfig>
<ext:VBoxLayoutConfig Align="Stretch" />
</LayoutConfig>
<Items>
<ext:TabPanel ID="TabPanel1" runat="server" ActiveTabIndex="0">
<Items>
<ext:Panel ID="Panel1" runat="server" Title="Panel1" Flex="1" Height="300">
</ext:Panel>
<ext:Panel ID="Panel2" runat="server" Title="Panel2" Flex="1" Height="300">
</ext:Panel>
</Items>
</ext:TabPanel>
</Items>
</ext:Viewport>
<ext:KeyMap ID="KeyMap1" runat="server" Target="App.Panel1">
<ext:KeyBinding Alt="true" StopEvent="true">
<Keys>
<ext:Key Code="W" />
</Keys>
<Listeners>
<Event Handler="Ext.Msg.alert('Hello','Panel1');" />
</Listeners>
</ext:KeyBinding>
</ext:KeyMap>
<ext:KeyMap ID="KeyMap2" runat="server" Target="App.Panel2">
<ext:KeyBinding Alt="true" StopEvent="true">
<Keys>
<ext:Key Code="W" />
</Keys>
<Listeners>
<Event Handler="Ext.Msg.alert('Hello','Panel2');" />
</Listeners>
</ext:KeyBinding>
</ext:KeyMap>
</form>
</body>
</html>

Daniil
Apr 02, 2012, 1:30 PM
Hi,

By default, non active tabs are not rendered. They are rendered when first time activated.

To change this behavior you can set up

DeferredRender="false"
for the TabPanel.

See also
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.tab.Panel-cfg-deferredRender

Though it will cause all tabs to be rendered initially - it can decrease the application performance. So, I would suggest to create KeyMaps on the fly via JavaScript within tabs AfterRender listener.

Also, please read the following related thread:
http://forums.ext.net/showthread.php?18171

Fredrik
Apr 02, 2012, 2:52 PM
DeferedRender="false" will work for me.