PDA

View Full Version : [CLOSED] Layout setActiveItem() replacement?



vadym.f
Apr 30, 2013, 6:14 PM
Hi,

I have the following v1.x code related to a Panel named PanelExplorer with AccordionLayout set:



PanelExplorer.layout.setActiveItem(App.MenuPanelFi le);
PanelExplorer.items.each(function (item) {{
if (item.menu.rendered) {{
item.clearSelection();
}}
}});
var menuId=getMenuId(); // Get a valid menu ID
PanelExplorer.getComponent('MenuPanelFile').setSel ection(menuId);


Aside from prefixing the objects with App, what changes are due for it to work in v2.2? The layout property is now string but getLayout() method is missing from the panel instance.

Vladimir
Apr 30, 2013, 6:25 PM
getLayout method is available
http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.container.AbstractContainer-method-getLayout

Please provide runable sample reproduces the issue

vadym.f
Apr 30, 2013, 7:08 PM
Hi Vladimir,

Please run the code sample below. Click on the "Test Layout" button to reproduce. Please advise what goes wrong here.

Quick Update: Sorry, this sample runs fine, I'm not sure what the difference between this code and mine so far. I will try to investigate.

Another update:
OK, it seems that App.PanelExplorer.getLayout() is there but it doesn't have the setActiveItem() method defined.



<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>

<html>
<head id="Head1" runat="server">
<title>AccordionLayout in Markup - Ext.NET Examples</title>
<script type="text/javascript">
var testLayoutClick = function () {
try {
Ext.Msg.alert("Layout is defined: ", App.PanelExplorer.getLayout());
}
catch (e) {
Ext.Msg.alert("Error", e.message);
}
};

</script>
</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Viewport ID="Viewport1" runat="server" Layout="BorderLayout">
<Items>
<ext:Panel ID="PanelExplorer"
runat="server"
Title="Accordion"
Width="250"
Maximizable="true"
BodyBorder="0"
Region="West"
Icon="ApplicationTileVertical"
Layout="AccordionLayout">
<TopBar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:Button ID="Button4" runat="server" Text="Test Layout">
<Listeners>
<Click Handler="testLayoutClick();"></Click>
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<Items>
<ext:TreePanel ID="TreePanel1" runat="server" Title="Online Users" RootVisible="false">
<Tools>
<ext:Tool Type="Refresh" />
</Tools>
<Root>
<ext:Node Text="Root">
<Children>
<ext:Node Text="Friends" Expanded="true">
<Children>
<ext:Node Text="Jack" Icon="User" Leaf="True" />
<ext:Node Text="Brian" Icon="User" Leaf="True" />
<ext:Node Text="Jon" Icon="User" Leaf="True" />
<ext:Node Text="Tim" Icon="User" Leaf="True" />
<ext:Node Text="Nige" Icon="User" Leaf="True" />
<ext:Node Text="Fred" Icon="User" Leaf="True" />
<ext:Node Text="Bob" Icon="User" Leaf="True" />
</Children>
</ext:Node>
<ext:Node Text="Family" Expanded="true">
<Children>
<ext:Node Text="Kelly" Icon="UserFemale" Leaf="True" />
<ext:Node Text="Sara" Icon="UserFemale" Leaf="True" />
<ext:Node Text="Zack" Icon="UserGreen" Leaf="True" />
<ext:Node Text="John" Icon="UserGreen" Leaf="True" />
</Children>
</ext:Node>
</Children>
</ext:Node>
</Root>
</ext:TreePanel>
<ext:Panel ID="Panel1" runat="server" Title="Settings" />
<ext:Panel ID="Panel2" runat="server" Title="Even More Stuff" />
<ext:Panel ID="Panel3" runat="server" Title="My Stuff" />
</Items>
</ext:Panel>
</Items>
</ext:Viewport>
</body>
</html>

Vladimir
Apr 30, 2013, 7:36 PM
Yes, Accordion layout has no setActiveItem method, please its members
http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.layout.container.Accordion

To make an item as active please expand required item


App.PanelExplorer.get(1).expand();


or



App.Panel1.expand();

vadym.f
May 01, 2013, 12:53 PM
Thanks Vladimir!

Will this approach work to select a menu item?


App.PanelExplorer.getComponent('MenuPanelFile').se tSelection(menuId);

Daniil
May 01, 2013, 4:19 PM
You should pass a menu item instance, not its id.

App.PanelExplorer.getComponent('MenuPanelFile').se tSelection(App.MenuItem1);

This should work as well.

App.PanelExplorer.getComponent('MenuPanelFile').se tSelection(App["menuItemId"]);

vadym.f
May 02, 2013, 11:28 AM
Thanks Daniil,

Please close this thread down.