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

Extjs gridpanel中的checkbox(复选框)根据某行的条件不能选中的解决方法

Le code spécifique est présenté ci-dessous :

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 Explanation:

1The red marked location is the key code;

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

3The code at the .listeners location indicates that a condition judgment is made 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 solution mentioned above is the method to prevent the checkbox from being selected according to certain conditions in the Extjs gridpanel. I hope it will be helpful to everyone. If you have any questions, please leave a message, and I will reply to everyone in time. I would also like to express my heartfelt thanks to everyone for their support of the Yanaohao 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 edited by humans, and does not assume any relevant legal liability. If you find any suspected copyright content, please send an email to: notice#oldtoolbag.com (When sending an email, please replace # with @ to report, and provide relevant evidence. Once verified, this site will immediately delete the infringing content.)