数据表 ..如何根据表格的单元格值更改单元格的颜色
DATA Table ... How to change the Color of cell as per the Cell Value Of Table
我正在使用数据表概念,但不知道如何根据单元格值更改单元格的颜色。我知道如何根据单元格值更改整行的颜色..这是我用于行的代码..我应该在哪里更改代码...??
$('#example').DataTable( {
//"bDestroy": true, // NOT Working THis Function Here ...!!!
dom: 'Bfrtip',
buttons: ['copy', 'csv', 'excel', 'pdf', 'print'],
retrieve: true,
//FOR COLOR CODING AS PER THE VALUES in THe ROW/ CELL..!!!-NOW IT is for the Entire Row .. !!
"fnRowCallback": function( nRow, myInfraArray)
{
if ( myInfraArray[3] == "" )
{
$('td', nRow).css('background-color', '#F08080');
}
else if ( myInfraArray[3] == "Not Availiable" )
{
$('td', nRow).css('background-color', '#F08080');
}
else if ( myInfraArray[3] >= 5 && myInfraArray[3] <= 15)
{
$('td', nRow).css('background-color', '#90EE90');
}
else if (myInfraArray[3] >= 0 && myInfraArray[3] <= 4 )
{
$('td', nRow).css('background-color', '#FFDAB9');
}
}
} );
我已经解决了它... :)这是根据单元格值更改单元格颜色的代码...
$('#example').DataTable( {
//"bDestroy": true, // NOT Working THis Function Here ...!!!
dom: 'Bfrtip',
buttons: ['copy', 'csv', 'excel', 'pdf', 'print'],
retrieve: true,
//FOR COLOR CODING AS PER THE VALUES in THe ROW/ CELL..!!!-NOW IT is for the Entire Row .. !!
"fnRowCallback": function( nRow, myInfraArray)
{
$(nRow).children().each(function(index, td, myInfraArray) {
if ($(td).html() == "") {
$(td).css("background-color", "#F08080");
} else if ($(td).html() == "Not Available") {
$(td).css("background-color", "#F08080");
} else if (($(td).html() >= 5 && $(td).html() <= 20))
{ $(td).css("background-color", "#90EE90");
} else if (($(td).html() >= 00 && $(td).html() <= 4) || ($(td).html()=="not working"))
$(td).css("background-color", "#FF3229");
$('table:last tr:nth-child(2) td:nth-child(2)').
css("background-color", "#cccccc");
} );
return nRow;
}
} );
相关文章:
- 我可以使用jqgrid的oncellselect事件根据单元格内容将文本颜色更改为蓝色吗
- 使用javascript下拉菜单更改表格单元格的颜色
- 数据表 ..如何根据表格的单元格值更改单元格的颜色
- 使用 javascript 为 HTML 表格单元格指定颜色
- Google Apps 脚本:尝试根据单元格的背景颜色发送电子邮件
- 如何在三次单击html5 / javascript / css时将表格单元格颜色更改为默认值
- 完整日历在鼠标悬停时更改单元格颜色
- 根据内容更改表格单元格颜色-上面的空单元格破坏了此代码
- 刷新时使用复选框保持单元格颜色的更改
- Lightswitch HTML Client 2013-根据表中的单元格值更改单元格颜色
- 在JQGrid中更改单元格颜色,同时单击“单元格”
- 更改表格中的单元格颜色
- 根据类别改变单元格颜色
- 根据数学计算的Javascript单元格颜色
- 谷歌图表API数据表单元格颜色
- Sencha ExtJS propertyeeditor网格单元格颜色
- Highcharts热图:任意设置单元格颜色
- Javascript如何在计时事件中更改单元格颜色
- 工作表中单元格颜色更改时的电子邮件触发器
- 在 jsp 中显示来自 servlet 的范围的动态单元格颜色