Solution that the checkbox of check box in Extjs gridpanel cannot be selected according to the conditions of a row

  • 2021-07-21 07:23:51
  • OfStack

The specific code is as follows:


Ext.define('AM.view.test.ReceiptList', { 
  extend: 'Ext.grid.Panel', 
  alias: 'widget.receiptlist', 
  id : 'receiptlist', 
  selModel : { 
    selType : 'checkboxmodel', 
    mode : 'SIMPLE', 
    checkOnly : true, 
    renderer : function(v,p,record) { 
      if (record.data.XR0003 == '0') { 
        return '<div class="x-grid-row-checker"> </div>'; 
      }else{ 
        return ''; 
      } 
    } 
  }, 
  listeners: { 
    beforeselect: function(grid, record, index, eOpts) { 
      if (record.get('XR0003')!=0) { 
        return false; 
      } 
    } 
  } 
}); 

Code description:

1. The red mark is the key code;

2. The code at renderer indicates that the check box is displayed only when the conditions are met during rendering;

3. The code at 3. listeners indicates that the monitor makes a condition judgment before selection. If it is not equal to 0, let it not be selected;

4. The two methods can be combined according to their own needs.


Related articles: