English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Solution to Make the Checkbox in Extjs Gridpanel Unselectable Based on Certain Row Conditions

The specific code is shown 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--checker"> </div>'; 
      }else{ 
        return ''; 
      } 
    } 
  }, 
  listeners: { 
    beforeselect: function(grid, record, index, eOpts) { 
      if (record.get('XR0003')!=0) { 
        return false; 
      } 
    } 
  } 
}); 

Code description:

1The red marked location is the key code;

2The code at the .renderer location represents that the checkbox is displayed only when the conditions are met during rendering.

3The code at the .listeners location represents the condition judgment before selection; if it is not equal to 0, it will not be selected.

4You can combine the two methods according to your own needs.

The above-mentioned solution is introduced by the editor for the Extjs gridpanel checkbox (checkbox) that cannot be selected according to the conditions of a certain row, hoping it will be helpful to everyone. If you have any questions, please leave a message, and the editor will reply to everyone in time. We are also very grateful for everyone's support of the Yelling Tutorial website!

Statement: The content of this article is from the Internet, and the copyright belongs to the original author. The content is contributed and uploaded by Internet users spontaneously. This website does not own the copyright, has not been manually edited, and does not assume any relevant legal liability. If you find any content suspected of copyright infringement, please send an email to: notice#oldtoolbag.com (Please replace # with @ when sending an email for reporting, and provide relevant evidence. Once verified, this site will immediately delete the content suspected of infringement.)

You May Also Like