【问题标题】:Extjs Grid - Add class to row when click a cell of rowExtjs Grid - 单击行的单元格时将类添加到行
【发布时间】:2013-07-01 22:22:39
【问题描述】:

当我单击下面的网格单元格时,我想将类添加到行
我尝试了三个选项,但没有工作。如何使它工作谢谢

listeners: {
        ,'cellclick': function (grid, td, cellIndex, record, tr, rowIndex, e, eOpts ) {
            // addclass to row
            Ext.fly(grid.getView().getRow(rowIndex)).addClass('bluerow'); // not working
            grid.getView().addRowCls(rowIndex, 'bluerow'); // not working
            Ext.get(e.target).addClass('bluerow'); // not working
        }
}

【问题讨论】:

    标签: extjs grid cell extjs4.1


    【解决方案1】:

    cellclick 中的网格参数已经是一个视图。请看一下cellclick 您可以直接添加 css 为:

    grid.addRowCls(rowIndex, 'bluerow');
    

    这里是fiddle

    【讨论】:

    • 使用 grid.removeRowCls 来删除 RowCls 并且它可以工作。但是对于 grid.getRowCls 呢?
    • @freestyle 如果您的意思是 getRowClass(),您必须自己覆盖它。检查 extjs 文档。
    • @freestyle 我使用 removeRowCls() 但它不起作用。你能帮帮我吗?
    【解决方案2】:

    试试下面的代码 sn-p:

    grid.getView().addRowCls(rowIndex,'bluerow'); 
    grid.getView().removeRowCls(rowIndex,'bluerow');
    

    【讨论】:

      猜你喜欢
      • 2022-11-30
      • 2015-11-10
      • 1970-01-01
      • 2012-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-14
      • 1970-01-01
      相关资源
      最近更新 更多