繁体   English   中英

在数据表中编辑后突出显示行

[英]highlight row after edit in datatables

我是Jquery和Javascript的新手。

我正在使用数据表来显示一些数据

我试图突出显示特定的行,即:在内联编辑后编辑的行。 我正在使用内联编辑(来自https://github.com/ejbeaty/CellEdit )。 我在“Advanced.js”中修改过的代码如下:

    function myCallbackFunction (updatedCell, updatedRow, oldValue) {



   if (updatedCell.data() == "Bradley")
        {
            console.log("highlight required for Name Bradley")
            $(updatedRow).css( "background-color", "Orange" )

        }

    console.log("The new value for the cell is: " + updatedCell.data());
    console.log("The old value for that cell was: " + oldValue);
    console.log("The values for each cell in that row are: " + updatedRow.data());
}

在回调函数中,我试图更改特定名称的背景颜色。 我可以看到console.log但颜色变化似乎没有占用。

以前不知道这个CellEdit插件,但它看起来非常好,体面和直接。 不是复制示例,有时最好从头开始生成一个小的最小示例。 看这个

var table = $('#example').DataTable({
}).MakeCellsEditable({
  onUpdate: function(cell, row, oldValue) { 
    if (cell.data() != oldValue) {
      row.nodes().to$().addClass('highlight')
    }   
  }
})  

我在评论中忘记了.nodes() ,对不起 - 但上面的工作 - > http://jsfiddle.net/Lccju5bq/

试试这个`

  if (updatedCell.data() == "Bradley")
    {
        console.log("highlight required for Name Bradley")
        var updatedRow = document.getElementbyId("updatedRow);
        updatedRow.style.background = 'black';

    }

暂无
暂无

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

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