【问题标题】:How to get checkbox in grid widgetcolumn from cellclick?如何从cellclick获取网格小部件列中的复选框?
【发布时间】:2016-05-17 11:46:18
【问题描述】:

我的复选框列:

{
   xtype: 'widgetcolumn',
   text: 'Selection',
   tdCls: 'actions',
   header: 'Selection',
   width: '5%',
   dataIndex: 'selection',
   widget: {
      xtype: 'checkbox',
      defaultBindProperty: 'disabled',
      listeners: {
         afterrender: function (chb) {
            var rec = chb.getWidgetRecord();
            chb.setValue(rec.get('selection'));
            chb.on('change', this.checkHandler);
            chb.setDisabled(rec.get('selection_disabled'));
         },
         scope: this
      }
   }
}

如何在 cellclick 网格事件中以编程方式获取设置值的复选框?在 cellclick 中,我需要更改复选框的值(cbox.setValue(!cbox.getValue()); 或相同)。

【问题讨论】:

    标签: extjs


    【解决方案1】:

    不确定这是否是最佳解决方案,但您可以这样做:

    {
        xtype: 'widgetcolumn',
        dataIndex: 'checked',
        flex: 1,
        text: 'Checked',
    
        widget: {
            xtype: 'checkbox'
        },
        onWidgetAttach: function(column, widget, record) {
            // Make sure your property / id pair is unique
            // You can use Ext.id() to generate id for your record and widget
            widget.widgetId = record.get('id');
        }
    }
    

    grid.on('cellclick', function(view, td, cellIndex, record) {
        var rowWidget = Ext.ComponentQuery.query('checkbox[widgetId=' + record.get('id') + ']')[0];
        if(rowWidget) {
            rowWidget.setValue(!rowWidget.getValue());
        }
    });
    

    Working fiddle

    【讨论】:

      猜你喜欢
      • 2019-09-24
      • 2015-01-29
      • 2018-09-24
      • 1970-01-01
      • 1970-01-01
      • 2011-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多