繁体   English   中英

在ext js网格中选择行时,选中复选框

[英]On selection of row in ext js grid checkbox gets selected

我将Ext.grid.GridPanel与Ext.grid.CheckboxSelectionModel一起使用以显示带有复选框列的网格。 但是,当我单击行复选框时也会被选中。

我希望在选择网格行时不要选中复选框。 有什么办法可以做到这一点。

以下是我的代码段。

var cboxSelModel =new Ext.grid.CheckboxSelectionModel({
                checkOnly : true,
                width:100,
                header: defaultVal, 
                id: 'test',
                locked: true,
                singleSelect: true,
                listeners: {
                    rowselect: function (sm, rIndex, keepExisting, record) {            
                        uncheckIndex = -1;
                        cIndex =rIndex; 
                        updateDefaultValue();
                    },
                    rowdeselect: function (sm, rIndex, keepExisting, record) {            
                        cIndex = -1;
                        uncheckIndex =rIndex;
                        updateDefaultValue();
                    }
                }
         });

grid = new Ext.grid.GridPanel({
                id:'grid',
                width:'99%',
                border:true,
                store: store,
                tbar: toolBar,
                autoscroll: false,
                height :'100px',
                autoHeight :false,
                sm: cboxSelModel,
                cm :cm,
                height:150,
                layout: 'fit',
                stateful: true,
                stateId: 'grid',
                autoScroll:true,
                enableColumnResize : false,
                enableColumnMove : false,
                viewConfig:{
                    forceFit:true,
                    scrollOffset:0 
                },
                autoFitColumns: true,
                listeners: {
                    afterrender: function() {
                        setSelectedRows();
                        var store=grid.getStore();
                        if(store.data.length > 0 ){
                            Ext.getCmp('btnSort').setDisabled(false);
                            Ext.getCmp('btnSort').setIconClass('bmcSort');
                        }
                    },delay: 1000,
                    cellClick :function(iView, iCellEl, iColIdx, iRecord, iRowEl, iRowIdx, iEvent){
                          storeindex = iCellEl;
                          var record = grid.store.getAt(iCellEl);
                          var dValue=record.get('displayValue');
                          var sValue=record.get('storedValue');
                          var dataArray = getListData();
                          sValue=dataArray[iCellEl][1];
                          sValue = Ext.util.Format.htmlDecode(sValue);
                          dValue = Ext.util.Format.htmlDecode(dValue);                        
                          document.getElementById(InputPageComp.ComponentVars.storedValue).value=sValue;
                          document.getElementById(InputPageComp.ComponentVars.displayValue).value=dValue;
                          document.getElementById('addbtn_id').style['display']= 'none'; 
                          document.getElementById('updatebtn_id').style['display']= 'block'; 
                          Ext.getCmp('btnRemove').setDisabled(false);
                          Ext.getCmp('btnRemove').setIconClass('bmcDeleteSLT');
                          grid.getSelectionModel().selectRow(iCellEl);

                      }

                 }        
         });

var sm = Ext.create('Ext.selection.CheckboxModel',{checkOnly:true});

我测试过了 它应该工作

尝试这样(在网格配置中):

selModel: {
    selType: 'checkboxmodel',
    checkOnly: true
}

小提琴: https : //fiddle.sencha.com/#view/editor&fiddle/1ncs

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM