[英]jQuery datatable - change cell value
我希望有人可以帮助我解决这个问题。 我正在使用具有较旧版本的datatables.net的旧应用程序,它使用该函数填充数据表并根据返回的名称向行中添加颜色。 下面的代码有效。
$(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');
}
}
}
我遇到的麻烦是:如果名称=“ LOST TOYS”和DollarValue = 0,则将DollarValue更改为显示为空字符串(即单元格中未显示任何值)。
我已经看过使用fnUpdate,但我无法读取正确的行和列。 它返回“未定义”。
任何建议,不胜感激。 谢谢!
我放屁了。 代码进入服务器端以获取数据。
这是信息的链接: 有关服务器端源的Datatables论坛帖子
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.