-/*!
- * Ext JS Library 3.3.1
- * Copyright(c) 2006-2010 Sencha Inc.
- * licensing@sencha.com
- * http://www.sencha.com/license
- */
-Ext.namespace('Ext.ux.menu');
-
-/**
- * @class Ext.ux.menu.ListMenu
+/**
+ * @class Ext.ux.grid.menu.ListMenu
* @extends Ext.menu.Menu
* This is a supporting class for {@link Ext.ux.grid.filter.ListFilter}.
* Although not listed as configuration options for this class, this class
* also accepts all configuration options from {@link Ext.ux.grid.filter.ListFilter}.
*/
-Ext.ux.menu.ListMenu = Ext.extend(Ext.menu.Menu, {
+Ext.define('Ext.ux.grid.menu.ListMenu', {
+ extend: 'Ext.menu.Menu',
+
/**
* @cfg {String} labelField
* Defaults to 'text'.
*/
'checkchange'
);
-
- Ext.ux.menu.ListMenu.superclass.constructor.call(this, cfg = cfg || {});
-
+
+ this.callParent([cfg = cfg || {}]);
+
if(!cfg.store && cfg.options){
var options = [];
for(var i=0, len=cfg.options.length; i<len; i++){
case 'string': options.push([value, value]); break;
}
}
-
- this.store = new Ext.data.Store({
- reader: new Ext.data.ArrayReader({id: 0}, ['id', this.labelField]),
+
+ this.store = Ext.create('Ext.data.ArrayStore', {
+ fields: ['id', this.labelField],
data: options,
listeners: {
'load': this.onLoad,
destroy : function () {
if (this.store) {
- this.store.destroy();
+ this.store.destroy();
}
- Ext.ux.menu.ListMenu.superclass.destroy.call(this);
+ this.callParent();
},
/**
var lastArgs = null;
return function(){
if(arguments.length === 0){
- Ext.ux.menu.ListMenu.superclass.show.apply(this, lastArgs);
+ this.callParent(lastArgs);
} else {
lastArgs = arguments;
if (this.loadOnShow && !this.loaded) {
this.store.load();
}
- Ext.ux.menu.ListMenu.superclass.show.apply(this, arguments);
+ this.callParent(arguments);
}
};
}(),
-
+
/** @private */
onLoad : function (store, records) {
- var visible = this.isVisible();
- this.hide(false);
-
- this.removeAll(true);
-
- var gid = this.single ? Ext.id() : null;
- for(var i=0, len=records.length; i<len; i++){
- var item = new Ext.menu.CheckItem({
- text: records[i].get(this.labelField),
- group: gid,
- checked: this.selected.indexOf(records[i].id) > -1,
- hideOnClick: false});
-
- item.itemId = records[i].id;
- item.on('checkchange', this.checkChange, this);
-
- this.add(item);
+ var me = this,
+ visible = me.isVisible(),
+ gid, item, itemValue, i, len;
+
+ me.hide(false);
+
+ me.removeAll(true);
+
+ gid = me.single ? Ext.id() : null;
+ for (i = 0, len = records.length; i < len; i++) {
+ itemValue = records[i].get('id');
+ item = Ext.create('Ext.menu.CheckItem', {
+ text: records[i].get(me.labelField),
+ group: gid,
+ checked: Ext.Array.contains(me.selected, itemValue),
+ hideOnClick: false,
+ value: itemValue
+ });
+
+ item.on('checkchange', me.checkChange, me);
+
+ me.add(item);
}
-
- this.loaded = true;
-
+
+ me.loaded = true;
+
if (visible) {
- this.show();
- }
- this.fireEvent('load', this, records);
+ me.show();
+ }
+ me.fireEvent('load', me, records);
},
/**
getSelected : function () {
return this.selected;
},
-
+
/** @private */
setSelected : function (value) {
value = this.selected = [].concat(value);
this.items.each(function(item){
item.setChecked(false, true);
for (var i = 0, len = value.length; i < len; i++) {
- if (item.itemId == value[i]) {
+ if (item.value == value[i]) {
item.setChecked(true, true);
}
}
}, this);
}
},
-
+
/**
* Handler for the 'checkchange' event from an check item in this menu
* @param {Object} item Ext.menu.CheckItem
var value = [];
this.items.each(function(item){
if (item.checked) {
- value.push(item.itemId);
+ value.push(item.value);
}
},this);
this.selected = value;
-
+
this.fireEvent('checkchange', item, checked);
- }
-});
\ No newline at end of file
+ }
+});