如何在单击按钮时在 extjs 中点击特定的行

How to strike a perticular row in extjs on click of button

我有一个带行的网格。我想在点击特定按钮时发出罢工。这是我的代码。

{ 
xtype: 'button', 
text: 'Exclude',
handler : function(){
    debugger;
    var cohartgrid = Ext.getCmp('abc');
    var cohartstore = cohartgrid.getStore();
    var record = Ext.getCmp('abc').getSelectionModel().getSelected();
    var st = cohartstore.getRange();
     if (record) {
        Ext.fly(row).addCls('row-deleted');// This line is not working. 
    }

    if(record.data.EXL == "No"){
       record.set("EXL","YES")
    }
}}

什么css我必须放。感谢您的帮助。

使用代码在所选行中添加 class:

rowIndex = cohartgrid.getStore().indexOf(selectedRecord);
cohartgrid.getView().addRowCls(rowIndex, 'row-deleted');

我在其他 post 回答过同类问题。在这里,您需要获取行的索引,然后使用 addClass 放置罢工 css。记得 extjs 3 不支持 addCls

     var selection = grid.getSelectionModel();
     for(var i=0;i<gridstore.data.length;i++){
      if(selection.isSelected(i)){
      var test = grid.getView().getRow(i);
      var dsd=Ext.fly(test);
      dsd.addClass('StrikeCSS'); // Placing css to that perticular row.
        }
  }

答案中的网格是您的网格。在选择中,您获取行索引并放置 Strike

.StrikeCSS {
  text-decoration: line-through !important;
   color : BLACK !important;    
}