日期:2014-05-16  浏览次数:20709 次

ExtJs4.0 扩展控件(itemselector)
JScript code

{
                        xtype: 'itemselector',
                        name: 'itemselector',
                        id: 'itemselector-Yfield',
                        anchor: '100%',
                        height: 300,

                        autoScroll: true,
                        hideLabel: true,
                        buttons: ["top", "add", "remove", "bottom"],
                        buttonsText: {
                            top: "添加所有项",
                            add: "添加选中项",
                            remove: "移除选中项",
                            bottom: "移除所有项"
                        },
                        imagePath: '@Url.Content("~/ux/css/images/")',
                        store: itemselectStore,
                        allowBlank: false,
                        blankText: '@Html.GetLocalText("Common_SelectAtLeastOneDim")', //请至少选择一个可用用户和组
                        multiselects: [
                                    { listTitle: '@Html.GetLocalText("WebMetaDataAccessDim")', height: 300 }, //可用用户和组
                                    {listTitle: '@Html.GetLocalText("WebMetaDataSelectDim")', id: 'selected', height: 300}//选择用户和组
                                ],
                        displayField: 'DIMmemberName',
                        valueField: 'DIMmemberId',
                        msgTarget: 'side'

                    }


为了实现将top的事件改成全选的事件,bottom实现全部反选的功能,代码如下

JScript code
                        Ext.override(Ext.ux.form.ItemSelector, {
                            onTopBtnClick: function () {       //将top的事件改成全选的事件
                                var me = this,
                                    fromList = me.fromField.boundList,
                                    allRec = fromList.getStore().getRange();

                                fromList.getStore().remove(allRec);
                                me.toField.boundList.getStore().add(allRec);
                            },
                            onBottomBtnClick: function () {
                                var me = this,
                                    toList = me.toField.boundList,
                                    allRec = toList.getStore().getRange();

                                toList.getStore().remove(allRec);
                                me.fromField.boundList.getStore().add(allRec);
                            }
                        });


有比较多的页面要用的上面这个扩展,于是我就将这个模块放到了一个JS文件(Common_SelectItem.js)里面,有用到的页面就引入Common_SelectItem.js文件,但是这样做就报错:cls is undefined,
JScript code
 override: function(cls, overrides) {
            if (cls.prototype.$className) {
                return cls.override(overrides);
            }
            else {
                Ext.apply(cls.prototype, overrides);
            }
        }
不知道怎么改,求帮助!!!

------解决方案--------------------
应该是你没导入itemselector那个js文件

bootstrap.js只是控制输出调式版本的ext核心或者是压缩版本的,ux之类可能需要自己手动导入,没有集成到ext核心里面,应为下面的代码输出undefined。。
JScript code
Ext.onReady(function () {
            alert(Ext.ux.form.ItemSelector)
        });

------解决方案--------------------
探讨
引用:
应该是你没导入itemselector那个js文件

bootstrap.js只是控制输出调式版本的ext核心或者是压缩版本的,ux之类可能需要自己手动导入,没有集成到ext核心里面,应为下面的代码输出undefined。。

JScript code

E