Как получить информацию о проверке CheckBox в сетке?

У меня есть EditorGridPanel, ColumnModel сетки включает TextField, ComboBox и CheckBox. После редактирования TextField или ComboBox срабатывает событие afteredit, которое содержит сведения об отредактированном поле. Когда я проверяю/снимаю флажок в поле CheckBox, нет события, которое дает какие-либо сведения о том, какой CheckBox нажат.


person Yarin Gold    schedule 29.05.2012    source источник
comment
Вы используете roweditor или celleditor?   -  person egerardus    schedule 29.05.2012


Ответы (2)


Модель выбора отображает столбец флажков, которые можно переключать для выбора или отмены выбора строк в сетке.

попробуйте применить слушателей к модели выбора флажка.

документы: Ext.selection. CheckboxModel-event-selectionchange

см.: пример

person MMT    schedule 29.05.2012
comment
CheckboxSelectionModel не имеет текстового заголовка и не может быть размещен в определенной позиции в столбцах сетки. - person Yarin Gold; 29.05.2012
comment
попробуйте установить injectCheckbox : Number/Boolean/String, чтобы установить положение столбца флажка docs.sencha.com/ext-js/4-0/#!/api/ - person MMT; 29.05.2012
comment
Использование extjs 2.2: / нет свойства injectCheckbox - person Yarin Gold; 29.05.2012

Используйте checkchange событие от Ext.ux.CheckColumn. Это дает rowIndex.

ИЗМЕНИТЬ

Если вы делаете гораздо больше развития в 2.2, я бы порекомендовал вам обновиться. Но если вы не можете, вы всегда можете попробовать добавить переопределение или расширить Ext.ux.CheckColumn, чтобы включить события более поздней версии. Я уверен, что этот код нужно будет изменить, чтобы сделать его совместимым с 2.2, но вот пример переопределения для включения необходимых событий - я понимаю, что я даже не уверен, был ли в 2.2 метод Ext.override, вам придется проверьте свои документы (код checkchange исходит прямо из API 4.1):

Ext.override(Ext.ux.CheckChange, {
    constructor: function() {
        this.addEvents(
            /**
             * @event beforecheckchange
             * Fires when before checked state of a row changes.
             * The change may be vetoed by returning `false` from a listener.
             * @param {Ext.ux.CheckColumn} this CheckColumn
             * @param {Number} rowIndex The row index
             * @param {Boolean} checked True if the box is to be checked
             */
            'beforecheckchange',
            /**
             * @event checkchange
             * Fires when the checked state of a row changes
             * @param {Ext.ux.CheckColumn} this CheckColumn
             * @param {Number} rowIndex The row index
             * @param {Boolean} checked True if the box is now checked
             */
            'checkchange'
        );
        this.callParent(arguments);
    },

    /**
     * @private
     * Process and refire events routed from the GridView's processEvent method.
     */
    processEvent: function(type, view, cell, recordIndex, cellIndex, e) {
        var me = this,
            key = type === 'keydown' && e.getKey(),
            mousedown = type == 'mousedown';

        if (mousedown || (key == e.ENTER || key == e.SPACE)) {
            var record = view.panel.store.getAt(recordIndex),
                dataIndex = me.dataIndex,
                checked = !record.get(dataIndex);

            // Allow apps to hook beforecheckchange
            if (me.fireEvent('beforecheckchange', me, recordIndex, checked) !== false) {
                record.set(dataIndex, checked);
                me.fireEvent('checkchange', me, recordIndex, checked);

                // Mousedown on the now nonexistent cell causes the view to blur, so stop it continuing.
                if (mousedown) {
                    e.stopEvent();
                }

                // Selection will not proceed after this because of the DOM update caused by the record modification
                // Invoke the SelectionModel unless configured not to do so
                if (!me.stopSelection) {
                    view.selModel.selectByPosition({
                        row: recordIndex,
                        column: cellIndex
                    });
                }

                // Prevent the view from propagating the event to the selection model - we have done that job.
                return false;
            } else {
                // Prevent the view from propagating the event to the selection model if configured to do so.
                return !me.stopSelection;
            }
        } else {
            return me.callParent(arguments);
        }
    },
});
person egerardus    schedule 29.05.2012
comment
Я использую extjs 2.2 и не имею события checkchangeevent в Ext.ux.CheckColumn - person Yarin Gold; 29.05.2012