Search code examples
javascriptextjsextjs3

Facing issue on Multiselect enabled Grid in EXTJS


I have a grid with checkboxselectionmodel. Here i have faced a problem, The delete button will be disabled when I am deselecting any of the selected record (still some records are selected). I need to make the delete button as enabled when any record is selected. Here is the code I am used,

    function setDetail(action, r){
        switch (action) {
            case 'update':                                                  
                Ext.getCmp('delete').enable();
            break;
            default:
                Ext.getCmp('delete').disable();
            break;
        }
    };

    var checkboxselection = new Ext.grid.CheckboxSelectionModel({
      singleSelect: false,
      listeners: {
        'selectionchange' : function(sm) {

        },
        rowselect       : function(sm, i, r) {
            selectedRecord.idProperty = r.get('pos');
            setDetail('update', r);
        },

        rowdeselect     : function () {
            setDetail();
        }

      }
    });

Thankz in advance....


Solution

  •     rowdeselect     : function () {
            setDetail();
        }
    

    This Part disables your delete button whenever you deselect even a single checkbox. The code is working fine. Your logic is wrong here. You can do this by maintaining a counter which changes based on every checkbox selection. (+1 if checked.. -1 if unchecked) and in your setDetail method based on the counter you can enable or disable your Delete button.