SuperBoxSelect: Использование Shift + щелчок для выбора нескольких элементов одновременно - PullRequest
0 голосов
/ 02 марта 2011

При реализации SuperBoxSelect (http://www.sencha.com/forum/showthread.php?69307-3.x-Ext.ux.form.SuperBoxSelect), я понял, что в настоящее время он не поддерживает выбор нескольких элементов с помощью Shift + клик. Кто-нибудь смог реализовать эту функцию или нашел аналогичный плагин, который предлагает эту функцию?

1 Ответ

0 голосов
/ 03 марта 2011
    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. Он просто назван по-другому, поэтому выделение прилипает к элементу, который вы переместили + щелкнули после того, как навели курсор мыши.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...