2014-08-29 53 views
0

我希望有人可以帮助我解决这个问题。 我正在使用旧版本的datatables.net查看遗留应用程序 它使用该函数来填充数据表并根据返回的名称向该行添加颜色。下面的代码工作。jQuery datatable - 更改单元格值

$(function() { 

$("#ProfileTable").dataTable({ 
    "bProcessing": true, 
    "bServerSide": true, 
    "bFilter": false, //Hide the search box 
    "bInfo": false, 
    "bPaginate": false, 
    "bLengthChange": false, 
    "sAjaxSource": 'DataTableHandler.ashx?dataTableId=ProfileTable', 
    "aoColumns": [ //aoColumns defines the properties of the table columns 
        { 
         "mDataProp": "Name", 
         "fnRender": function (o) { 
          return SetToolTip(o); 
         } 
        }, 
        { 
         "mDataProp": "DollarValue", 
         "fnRender": function (o) { 
          return accounting.formatMoney(dollarValue); 
         } 
         , 
         "bUseRendered": false, 
         "sClass": "dataTableTextAlignRight" 
        } 
    ], 
    "fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) { 

     //Highlight the row colors based on the Name. It must be identical to what is being retrieved from the database 
     var columnData = aData["Name"]; 
     var div = document.createElement("div"); 
     div.innerHTML = columnData; 

     if (div.innerText == "TOYS" { 
      $('td', nRow).css('background-color', '#E0E0E0'); 
     } 

     if (div.innerText == "LOST TOYS") { 
      $('td', nRow).css('background-color', '#BDBDBD'); 
     } 
    } 
} 

什么我在使用麻烦的是:如果Name =“LOST玩具”和DollarValue = 0然后改变DollarValue显示为空字符串(即,没有在单元格中显示的值)。

我已经看过使用fnUpdate,但我无法让它读取正确的行和列。它回来了“未定义”。

任何建议,非常感谢。 谢谢!

回答

相关问题