SuperBoxSelect:使用Shift +单击一次选择多个项目

时间:2011-03-01 21:52:02

标签: plugins extjs

实施SuperBoxSelect(http://www.sencha.com/forum/showthread.php?69307-3.x-Ext.ux.form.SuperBoxSelect)时,我意识到它目前不支持shift +单击选择多个项目。有没有人能够实现此功能或找到提供此功能的类似插件?

1 个答案:

答案 0 :(得分:0)

    beforeadditem:function(self, recordValue) {
        var start = 0;
        var end = 0;
        var record = this.findRecord(this.valueField, recordValue);
        var recordIndex = this.store.indexOf(record);
        if(window.event.shiftKey) {
            this.multiSelectMode = true;
            if(this.firstChoiceIndex == undefined) {
                this.firstChoiceIndex = recordIndex;
                this.view.all.item(recordIndex).addClass('x-combo-selected-shift');
                return false;
            } else {
                this.secondChoiceIndex = recordIndex;
                if(this.firstChoiceIndex > this.secondChoiceIndex) {
                    start = this.secondChoiceIndex;
                    end = this.firstChoiceIndex;
                } else if(this.secondChoiceIndex > this.firstChoiceIndex) {
                    start = this.firstChoiceIndex;
                    end = this.secondChoiceIndex;
                }
                var selectedRecords = this.store.getRange(start, end);
                Ext.each(selectedRecords, function(item, index, allitems) {
                    self.addRecord(item)
                });
                this.firstChoiceIndex = undefined;
                this.secondChoiceIndex = undefined;
                return false;
            }
        } else {
            this.firstChoiceIndex = undefined;
            this.secondChoiceIndex = undefined;
            return true;
        }
    }

添加该侦听器并且它可以正常工作。 x-combo-selected-shift类与x-combo-selected类相同。它只是命名为不同,因此突出显示会粘贴到您移动后单击的项目。