我想做一个extjs gridpanel,里边有CheckboxSelectionModel,做好之后发现不能选中复选框。后来发现整个表格内的文字都不能选中。以前做表格的时候都没有遇到这种问题,就做这个表格式出问题了。网上说是css问题,给的解决方案是extjs2。2版本的,我试了一下,不好用。

解决方案 »

  1.   

    //重写了Ext.grid.GridView表格的样式,支持选择单元格,便于复制
    if (!Ext.grid.GridView.prototype.templates) {
        Ext.grid.GridView.prototype.templates = {};
    }
    Ext.grid.GridView.prototype.templates.cell = new Ext.Template(
         '<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} x-selectable {css}" style="{style}" tabIndex="0" {cellAttr}>',
         '<div class="x-grid3-cell-inner x-grid3-col-{id}" {attr}>{value}</div>',
         '</td>'
    );   
      

  2.   

    2.2 的我也用过,勾选checkbox时是可以选中这行的呀。是不是代码有没有问题
      

  3.   

    var bsm = new Ext.grid.CheckboxSelectionModel(); bacterinrecordqueryGrid = new Ext.grid.GridPanel({
    title : '疫苗记录信息',
    renderTo : 'bgrid',
    height : '340',
    store : bacterinrecordqueryStore,
    // Align:'center',
    sm : bsm,
    columns : [bsm,
    // 自动行号
    new Ext.grid.RowNumberer({
    header : "序号",
    width : 40,
    renderer : function(value, metadata,
    record, rowIndex) {
    return bacterinrecordrecord_start + 1
    + rowIndex;
    }
    }), {
    header : '编号',
    dataIndex : 'bacterinrecord.bacterinid',
    width : 100,
    // 隐藏列
    hidden : true }, {
    header : '名称',
    dataIndex : 'bacterinrecord.name',
    width : 130
    }, {
    header : '数量',
    dataIndex : 'bacterinrecord.count',
    width : 100
    }, {
    header : '临界值',
    dataIndex : 'bacterinrecord.threshold',
    width : 100
    }, {
    header : '输入代码',
    dataIndex : 'bacterinrecord.inputcode',
    width : 100
    }, {
    header : '类型',
    dataIndex : 'bacterinrecord.bacterintype',
    width : 100
    }, {
    header : '单位',
    dataIndex : 'bacterinrecord.bacterinunit',
    width : 100
    }, {
    header : '属性',
    dataIndex : 'bacterinrecord.bacterinproperty',
    width : 100
    }, {
    header : '备注',
    dataIndex : 'bacterinrecord.re',
    width : '100%'
    }],
    // width : '430',
    tbar : [{
    text : ' 新建 ',
    tooltip : '新建',
    iconCls : 'add',
    handler : function() {
    bacterinrecordadd();
    }
    }, '-', {
    text : '修改',
    tooltip : '修改',
    iconCls : 'edit',
    handler : function() {
    bacterinrecordupdate();
    }
    }, '-', {
    text : '删除',
    tooltip : '删除',
    iconCls : 'del',
    handler : function() {
    del(bacterinrecordqueryGrid,
    bacterinrecordqueryStore,
    "bacterin/del_Bacterinrecord.action",
    'bacterinrecord.bacterinid');
    }
    }],
    bbar : [{
    xtype : 'paging',
    pageSize : 10,
    store : bacterinrecordqueryStore,
    displayInfo : true,
    beforePageText : "第",
    afterPageText : "/ {0}页",
    firstText : "首页",
    prevText : "上一页",
    nextText : "下一页",
    lastText : "尾页",
    refreshText : "刷新",
    displayMsg : "当前显示记录从 {0} - {1} 总 {2} 条记录",
    emptyMsg : "没有相关记录!",
    doLoad : function(start) {
    bacterinrecordrecord_start = start;
    var o = {}, pn = this.paramNames;
    o[pn.start] = start; this.store.load({
    params : o
    }); } }]
    });
      

  4.   

    1.new Ext.grid.RowNumberer({
                                        header : "序号",
                                        width : 40,
                                        renderer : function(value, metadata,
                                                record, rowIndex) {
                                            return bacterinrecordrecord_start + 1
                                                    + rowIndex;
                                        }
                                    }),// 不要这个自动行试试
    2.dataIndex : 'bacterinrecord.bacterintype',//dataIndex带‘.’还真没试过,为啥要这样用啊。不知道是否是这个原因。改改试试
      

  5.   

    width=‘100%’写错了,换成width=100