1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-menu.CheckItem-method-constructor'><span id='Ext-menu.CheckItem'>/**
2 </span></span> * @class Ext.menu.CheckItem
3 * @extends Ext.menu.Item
5 A menu item that contains a togglable checkbox by default, but that can also be a part of a radio group.
6 {@img Ext.menu.CheckItem/Ext.menu.CheckItem.png Ext.menu.CheckItem component}
8 Ext.create('Ext.menu.Menu', {
11 floating: false, // usually you want this set to True (default)
12 renderTo: Ext.getBody(), // usually rendered by it's containing component
14 xtype: 'menucheckitem',
17 xtype: 'menucheckitem',
18 text: 'select specific',
27 * @xtype menucheckitem
30 * @param {Object} config The config object
33 Ext.define('Ext.menu.CheckItem', {
34 extend: 'Ext.menu.Item',
35 alias: 'widget.menucheckitem',
37 <span id='Ext-menu.CheckItem-cfg-checkedCls'> /**
38 </span> * @cfg {String} checkedCls
39 * The CSS class used by {@link #cls} to show the checked state.
40 * Defaults to `Ext.baseCSSPrefix + 'menu-item-checked'`.
43 checkedCls: Ext.baseCSSPrefix + 'menu-item-checked',
44 <span id='Ext-menu.CheckItem-cfg-uncheckedCls'> /**
45 </span> * @cfg {String} uncheckedCls
46 * The CSS class used by {@link #cls} to show the unchecked state.
47 * Defaults to `Ext.baseCSSPrefix + 'menu-item-unchecked'`.
50 uncheckedCls: Ext.baseCSSPrefix + 'menu-item-unchecked',
51 <span id='Ext-menu.CheckItem-cfg-groupCls'> /**
52 </span> * @cfg {String} groupCls
53 * The CSS class applied to this item's icon image to denote being a part of a radio group.
54 * Defaults to `Ext.baseCSSClass + 'menu-group-icon'`.
55 * Any specified {@link #iconCls} overrides this.
58 groupCls: Ext.baseCSSPrefix + 'menu-group-icon',
60 <span id='Ext-menu.CheckItem-cfg-hideOnClick'> /**
61 </span> * @cfg {Boolean} hideOnClick
62 * Whether to not to hide the owning menu when this item is clicked.
63 * Defaults to `false` for checkbox items, and to `true` for radio group items.
68 afterRender: function() {
71 me.checked = !me.checked;
72 me.setChecked(!me.checked, true);
75 initComponent: function() {
78 <span id='Ext-menu.CheckItem-event-beforecheckchange'> /**
79 </span> * @event beforecheckchange
80 * Fires before a change event. Return false to cancel.
81 * @param {Ext.menu.CheckItem} this
82 * @param {Boolean} checked
86 <span id='Ext-menu.CheckItem-event-checkchange'> /**
87 </span> * @event checkchange
88 * Fires after a change event.
89 * @param {Ext.menu.CheckItem} this
90 * @param {Boolean} checked
95 me.callParent(arguments);
97 Ext.menu.Manager.registerCheckable(me);
101 me.iconCls = me.groupCls;
103 if (me.initialConfig.hideOnClick !== false) {
104 me.hideOnClick = true;
109 <span id='Ext-menu.CheckItem-method-disableCheckChange'> /**
110 </span> * Disables just the checkbox functionality of this menu Item. If this menu item has a submenu, that submenu
111 * will still be accessible
113 disableCheckChange: function() {
116 me.iconEl.addCls(me.disabledCls);
117 me.checkChangeDisabled = true;
120 <span id='Ext-menu.CheckItem-method-enableCheckChange'> /**
121 </span> * Reenables the checkbox functionality of this menu item after having been disabled by {@link #disableCheckChange}
123 enableCheckChange: function() {
126 me.iconEl.removeCls(me.disabledCls);
127 me.checkChangeDisabled = false;
130 onClick: function(e) {
132 if(!me.disabled && !me.checkChangeDisabled && !(me.checked && me.group)) {
133 me.setChecked(!me.checked);
135 this.callParent([e]);
138 onDestroy: function() {
139 Ext.menu.Manager.unregisterCheckable(this);
140 this.callParent(arguments);
143 <span id='Ext-menu.CheckItem-method-setChecked'> /**
144 </span> * Sets the checked state of the item
145 * @param {Boolean} checked True to check, false to uncheck
146 * @param {Boolean} suppressEvents (optional) True to prevent firing the checkchange events. Defaults to `false`.
149 setChecked: function(checked, suppressEvents) {
151 if (me.checked !== checked && (suppressEvents || me.fireEvent('beforecheckchange', me, checked) !== false)) {
153 me.el[checked ? 'addCls' : 'removeCls'](me.checkedCls)[!checked ? 'addCls' : 'removeCls'](me.uncheckedCls);
155 me.checked = checked;
156 Ext.menu.Manager.onCheckChange(me, checked);
157 if (!suppressEvents) {
158 Ext.callback(me.checkHandler, me.scope, [me, checked]);
159 me.fireEvent('checkchange', me, checked);
164 </pre></pre></body></html>