3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js"><div id="cls-Ext.menu.CheckItem"></div>/**
9 * @class Ext.menu.CheckItem
10 * @extends Ext.menu.Item
11 * Adds a menu item that contains a checkbox by default, but can also be part of a radio group.
13 * Creates a new CheckItem
14 * @param {Object} config Configuration options
15 * @xtype menucheckitem
17 Ext.menu.CheckItem = function(config){
18 Ext.menu.CheckItem.superclass.constructor.call(this, config);
20 <div id="event-Ext.menu.CheckItem-beforecheckchange"></div>/**
21 * @event beforecheckchange
22 * Fires before the checked value is set, providing an opportunity to cancel if needed
23 * @param {Ext.menu.CheckItem} this
24 * @param {Boolean} checked The new checked value that will be set
27 <div id="event-Ext.menu.CheckItem-checkchange"></div>/**
29 * Fires after the checked value has been set
30 * @param {Ext.menu.CheckItem} this
31 * @param {Boolean} checked The checked value that was set
35 <div id="method-Ext.menu.CheckItem-checkHandler"></div>/**
36 * A function that handles the checkchange event. The function is undefined by default, but if an implementation
37 * is provided, it will be called automatically when the checkchange event fires.
38 * @param {Ext.menu.CheckItem} this
39 * @param {Boolean} checked The checked value that was set
40 * @method checkHandler
42 if(this.checkHandler){
43 this.on('checkchange', this.checkHandler, this.scope);
45 Ext.menu.MenuMgr.registerCheckable(this);
47 Ext.extend(Ext.menu.CheckItem, Ext.menu.Item, {
48 <div id="cfg-Ext.menu.CheckItem-group"></div>/**
50 * All check items with the same group name will automatically be grouped into a single-select
51 * radio button group (defaults to '')
53 <div id="cfg-Ext.menu.CheckItem-itemCls"></div>/**
54 * @cfg {String} itemCls The default CSS class to use for check items (defaults to "x-menu-item x-menu-check-item")
56 itemCls : "x-menu-item x-menu-check-item",
57 <div id="cfg-Ext.menu.CheckItem-groupClass"></div>/**
58 * @cfg {String} groupClass The default CSS class to use for radio group check items (defaults to "x-menu-group-item")
60 groupClass : "x-menu-group-item",
62 <div id="cfg-Ext.menu.CheckItem-checked"></div>/**
63 * @cfg {Boolean} checked True to initialize this checkbox as checked (defaults to false). Note that
64 * if this checkbox is part of a radio group (group = true) only the last item in the group that is
65 * initialized with checked = true will be rendered as checked.
70 ctype: "Ext.menu.CheckItem",
73 onRender : function(c){
74 Ext.menu.CheckItem.superclass.onRender.apply(this, arguments);
76 this.el.addClass(this.groupClass);
80 this.setChecked(true, true);
86 Ext.menu.MenuMgr.unregisterCheckable(this);
87 Ext.menu.CheckItem.superclass.destroy.apply(this, arguments);
90 <div id="method-Ext.menu.CheckItem-setChecked"></div>/**
91 * Set the checked state of this item
92 * @param {Boolean} checked The new checked value
93 * @param {Boolean} suppressEvent (optional) True to prevent the checkchange event from firing (defaults to false)
95 setChecked : function(state, suppressEvent){
96 if(this.checked != state && this.fireEvent("beforecheckchange", this, state) !== false){
98 this.container[state ? "addClass" : "removeClass"]("x-menu-item-checked");
100 this.checked = state;
101 if(suppressEvent !== true){
102 this.fireEvent("checkchange", this, state);
108 handleClick : function(e){
109 if(!this.disabled && !(this.checked && this.group)){// disable unselect on radio item
110 this.setChecked(!this.checked);
112 Ext.menu.CheckItem.superclass.handleClick.apply(this, arguments);
115 Ext.reg('menucheckitem', Ext.menu.CheckItem);</pre>
\r