X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/0494b8d9b9bb03ab6c22b34dae81261e3cd7e3e6:/examples/ux/gridfilters/menu/ListMenu.js..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/examples/ux/grid/menu/ListMenu.js diff --git a/examples/ux/gridfilters/menu/ListMenu.js b/examples/ux/grid/menu/ListMenu.js similarity index 71% rename from examples/ux/gridfilters/menu/ListMenu.js rename to examples/ux/grid/menu/ListMenu.js index 95a78085..4fac0018 100644 --- a/examples/ux/gridfilters/menu/ListMenu.js +++ b/examples/ux/grid/menu/ListMenu.js @@ -1,19 +1,13 @@ -/*! - * 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'. @@ -47,9 +41,9 @@ Ext.ux.menu.ListMenu = Ext.extend(Ext.menu.Menu, { */ '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 -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); }, /** @@ -141,7 +140,7 @@ Ext.ux.menu.ListMenu = Ext.extend(Ext.menu.Menu, { getSelected : function () { return this.selected; }, - + /** @private */ setSelected : function (value) { value = this.selected = [].concat(value); @@ -150,14 +149,14 @@ Ext.ux.menu.ListMenu = Ext.extend(Ext.menu.Menu, { 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 @@ -167,11 +166,11 @@ Ext.ux.menu.ListMenu = Ext.extend(Ext.menu.Menu, { 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 + } +});