【问题标题】:EXTJS disable checkbox in checkcolumnEXTJS 禁用检查列中的复选框
【发布时间】:2017-04-27 03:03:59
【问题描述】:

我想根据其他列的值禁用某一行的特定复选框。

我看了here的问题。但是这里所有的答案都只是修改了css。

我不想要更新后的 css 。我想真正禁用单击复选框。

有什么方法可以实现吗?

【问题讨论】:

    标签: extjs checkbox grid extjs4.1


    【解决方案1】:

    我的 ExtJS 4 解决方案

    {
       xtype: 'checkcolumn',
       dataIndex: 'Check',
       width: 30,
       renderer: function (value, metaData, record) {
           return record.get('isDisabled') ? '' :
                  (new Ext.grid.column.CheckColumn()).renderer(value);
       }
    }
    

    【讨论】:

      【解决方案2】:

      检查这个小提琴

      https://fiddle.sencha.com/#view/editor&fiddle/1l26

      我已经使用编辑器复选框和检查列完成了这项工作。

      【讨论】:

      • 您刚刚完全禁用了复选框的编辑功能。我只想禁用其中的几个
      • 在checkchange之前在监听器中写一个条件
      • 条件并不重要,反正我的想法和你做的不一样。
      【解决方案3】:

      你也可以这样做
      检查小提琴:
      https://fiddle.sencha.com/#view/editor&fiddle/1maa

          var userStore = Ext.create('Ext.data.Store', {
          data: [{
              "id": 1,
              "abbr": "AL",
              "name": "Alabama",
              "completed":false
          }, {
              "id": 2,
              "abbr": "AK",
              "name": "Alaska",
              "completed":false
          }, {
              "id": 3,
              "abbr": "AZ",
              "name": "Arizona",
              "completed":false
          }]
      });
      
      Ext.create('Ext.grid.Panel', {
          renderTo: document.body,
          store: userStore,
          width: 400,
          height: 200,
          title: 'Application Users',
          columns: [{
              width: 25,
              align: 'left',
              xtype: 'checkcolumn',
              tdCls: 'checkBoxColum',
              dataIndex: 'completed',
              renderer: function (value, meta, record, row, col) {
                  /* Permission Check */
                  var me = this;
      
                  if(record.data.id==1)
                  {
                      meta['tdCls'] = 'x-item-disabled';
                  }else
                  {
                      meta['tdCls'] = '';
                  }
                  return new Ext.ux.CheckColumn().renderer(value);
              }
          }, {
              text: 'name',
              width: 100,
              sortable: false,
              hideable: false,
              dataIndex: 'name'
          }]
      });
      

      【讨论】:

      • 你已经为 extjs 6.2.1 做了这个。我尝试使用 extjs 4.1。此解决方案不适用于它。
      • @AdityaKorti 在 Ext 4 中,Ext.ux.CheckColumn 是一个不包含在 Ext 框架中的扩展。
      • @AdityaKorti 请查看此链接以获取更多信息sencha.com/forum/showthread.php?243045-grid-with-checkcolumn
      猜你喜欢
      • 1970-01-01
      • 2012-02-08
      • 1970-01-01
      • 2012-06-16
      • 1970-01-01
      • 2013-12-07
      • 2012-02-23
      • 2011-04-03
      • 2016-07-04
      相关资源
      最近更新 更多