Thursday, January 15, 2015

Extjs 5.1.0 Checkbox of GridPanel deselect event not working. checkboxmodel deselect not working


I think, this is a bug in Extjs 5.1.0 for CheckboxModel selectionchange doesn't fire when unselect rows.

Add below code where you define selModel:

selectWithEventMulti: function(record, e, isSelected) {
            var me = this;

            if (!e.shiftKey && !e.ctrlKey && e.getTarget(me.checkSelector)) {
                if (isSelected) {
                    me.doDeselect(record); // Second param here is suppress event, not "keep selection"
                } else {
                    me.doSelect(record, true);
                }
            } else {
                me.callParent([record, e, isSelected]);
            }
        },

After adding this above code, your selModel should be like this:

this.selModel = new Ext.selection.CheckboxModel( {
         allowDeselect: true,
         checkOnly: false,
         pruneRemoved: false,
         ignoreRightMouseSelection: true,
         injectCheckbox: 0,

    // ** Newly added code to fix bug
    selectWithEventMulti: function(record, e, isSelected) {
            var me = this;

            if (!e.shiftKey && !e.ctrlKey && e.getTarget(me.checkSelector)) {
                if (isSelected) {
                    me.doDeselect(record); // Second param here is suppress event, not "keep selection"
                } else {
                    me.doSelect(record, true);
                }
            } else {
                me.callParent([record, e, isSelected]);
            }
        },
   
// *************************
        showHeaderCheckbox: true,
         listeners: {
            deselect: function( obj, record, index, eOpts ) {
               alert("check box deselect");
            },
            select: function( obj, record, index, eOpts ) {
               alert("check box select");
            }
         },

Reference: http://www.sencha.com/forum/showthread.php?295764

No comments:

Post a Comment

You can put your comments here (Either feedback or your Question related to blog)