3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js"><div id="cls-Ext.menu.CheckItem"></div>/**
10 * @class Ext.menu.CheckItem
11 * @extends Ext.menu.Item
12 * Adds a menu item that contains a checkbox by default, but can also be part of a radio group.
14 * Creates a new CheckItem
15 * @param {Object} config Configuration options
16 * @xtype menucheckitem
18 Ext.menu.CheckItem = Ext.extend(Ext.menu.Item, {
19 <div id="cfg-Ext.menu.CheckItem-group"></div>/**
21 * All check items with the same group name will automatically be grouped into a single-select
22 * radio button group (defaults to '')
24 <div id="cfg-Ext.menu.CheckItem-itemCls"></div>/**
25 * @cfg {String} itemCls The default CSS class to use for check items (defaults to "x-menu-item x-menu-check-item")
27 itemCls : "x-menu-item x-menu-check-item",
28 <div id="cfg-Ext.menu.CheckItem-groupClass"></div>/**
29 * @cfg {String} groupClass The default CSS class to use for radio group check items (defaults to "x-menu-group-item")
31 groupClass : "x-menu-group-item",
33 <div id="cfg-Ext.menu.CheckItem-checked"></div>/**
34 * @cfg {Boolean} checked True to initialize this checkbox as checked (defaults to false). Note that
35 * if this checkbox is part of a radio group (group = true) only the last item in the group that is
36 * initialized with checked = true will be rendered as checked.
41 ctype: "Ext.menu.CheckItem",
43 initComponent : function(){
44 Ext.menu.CheckItem.superclass.initComponent.call(this);
46 <div id="event-Ext.menu.CheckItem-beforecheckchange"></div>/**
47 * @event beforecheckchange
48 * Fires before the checked value is set, providing an opportunity to cancel if needed
49 * @param {Ext.menu.CheckItem} this
50 * @param {Boolean} checked The new checked value that will be set
53 <div id="event-Ext.menu.CheckItem-checkchange"></div>/**
55 * Fires after the checked value has been set
56 * @param {Ext.menu.CheckItem} this
57 * @param {Boolean} checked The checked value that was set
61 <div id="method-Ext.menu.CheckItem-checkHandler"></div>/**
62 * A function that handles the checkchange event. The function is undefined by default, but if an implementation
63 * is provided, it will be called automatically when the checkchange event fires.
64 * @param {Ext.menu.CheckItem} this
65 * @param {Boolean} checked The checked value that was set
66 * @method checkHandler
68 if(this.checkHandler){
69 this.on('checkchange', this.checkHandler, this.scope);
71 Ext.menu.MenuMgr.registerCheckable(this);
75 onRender : function(c){
76 Ext.menu.CheckItem.superclass.onRender.apply(this, arguments);
78 this.el.addClass(this.groupClass);
82 this.setChecked(true, true);
88 Ext.menu.MenuMgr.unregisterCheckable(this);
89 Ext.menu.CheckItem.superclass.destroy.apply(this, arguments);
92 <div id="method-Ext.menu.CheckItem-setChecked"></div>/**
93 * Set the checked state of this item
94 * @param {Boolean} checked The new checked value
95 * @param {Boolean} suppressEvent (optional) True to prevent the checkchange event from firing (defaults to false)
97 setChecked : function(state, suppressEvent){
98 var suppress = suppressEvent === true;
99 if(this.checked != state && (suppress || this.fireEvent("beforecheckchange", this, state) !== false)){
101 this.container[state ? "addClass" : "removeClass"]("x-menu-item-checked");
103 this.checked = state;
105 this.fireEvent("checkchange", this, state);
111 handleClick : function(e){
112 if(!this.disabled && !(this.checked && this.group)){// disable unselect on radio item
113 this.setChecked(!this.checked);
115 Ext.menu.CheckItem.superclass.handleClick.apply(this, arguments);
118 Ext.reg('menucheckitem', Ext.menu.CheckItem);</pre>
\r