PDA

View Full Version : [CLOSED] How to check a menu item on the client?



vadym.f
Aug 02, 2013, 4:20 PM
Hi,

Please advise how to properly check a menu item on the client. This sample runs fine but doesn't do the trick.


<%@ Page Language="C#" %>
<%@ 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 id="Head1" runat="server">
<title>Ext.Net 2.x</title>
<ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" Mode="Script" />
<ext:ResourcePlaceHolder ID="ResourcePlaceHolder2" runat="server" Mode="Style" />
<script type="text/javascript">
var checkMenuItem = function () {
var menuSkin = App.MenuSkin;
var newTheme = "Neptune";
menuSkin.items.each(function (item) {
if (item.text == newTheme) {
item.checked = true;
}
});
};
</script>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server">
</ext:ResourceManager>
<ext:Viewport runat="server" Layout="FitLayout">
<Items>
<ext:Panel runat="server">
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button ID="Button1" runat="server" Text="Check Neptune Theme">
<Listeners>
<Click Handler="checkMenuItem();" />
</Listeners>
</ext:Button>
<ext:Button ID="ButtonTheme" runat="server" Icon="Paintcan" Text="Select Theme..." AutoDataBind="true" >
<Menu>
<ext:Menu ID="MenuSkin" runat="server">
<Items>
<ext:CheckMenuItem ID="MenuItemDefault" runat="server" Text="Default" Group="theme" Checked="true" />
<ext:CheckMenuItem ID="MenuItemGray" runat="server" Text="Gray" Group="theme" />
<ext:CheckMenuItem ID="MenuItemNeptune" runat="server" Text="Neptune" Group="theme" />
<ext:CheckMenuItem ID="MenuItemAccess" runat="server" Text="Access" Group="theme" />
</Items>
</ext:Menu>
</Menu>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
</ext:Panel>
</Items>
</ext:Viewport>
</form>
</body>
</html>

Daniil
Aug 02, 2013, 4:38 PM
Hi Vadym,

Please use:

item.setChecked(true);
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.menu.CheckItem-method-setChecked

P.S. We much appreciate that you always provide us with runnable samples.

vadym.f
Aug 02, 2013, 4:46 PM
Thanks much Daniil! I did have a sneaking suspicion that setting the property was wrong :). Please mark this question as closed.