遇到一些麻烦,希望有人能帮我指明一个方向。因为我是个新手,所以我已经把剧本分给我自己了。我试图根据字段的值突出显示特定行中的某些值。
我无法让它突出显示表中的实际字段,只有标题。这可能是服务器端处理的问题,还是在填充表之前运行突出显示脚本?
脚本,用于数据表的下载按钮集成
<script>
TableTools.BUTTONS.download = {
"sAction": "text",
"sTag": "default",
"sFieldBoundary": "",
"sFieldSeperator": "\t",
"sNewLine": "<br>",
"sToolTip": "",
"sButtonClass": "DTTT_button_text",
"sButtonClassHover": "DTTT_button_text_hover",
"sButtonText": "Download",
"mColumns": "all",
"bHeader": true,
"bFooter": true,
"sDiv": "",
"fnMouseover": null,
"fnMouseout": null,
"fnClick": function( nButton, oConfig ) {
var oParams = this.s.dt.oApi._fnAjaxParameters( this.s.dt );
var iframe = document.createElement('iframe');
iframe.style.height = "0px";
iframe.style.width = "0px";
iframe.src = oConfig.sUrl+"?"+$.param(oParams);
document.body.appendChild( iframe );
},
"fnSelect": null,
"fnComplete": null,
"fnInit": null
};
</script>用于填充表的脚本
<script>
$('#cluster_dataTables').dataTable( {
"bprocessing": true,
"bserverSide": true,
"sAjaxSource": "../scripts/data.php",
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"aButtons": [{
"sExtends": "download",
"sButtonText": "Download CSV",
"sUrl": "../scripts/data_csv.php"
}]
},
} );
</script> 执行高亮显示的脚本
<script>
$('#cluster_dataTables td:nth-child(2)').highlight('True'); //table test
$('#cluster_dataTables th:nth-child(2)').highlight('Enabled'); //head test
</script>发布于 2014-09-05 14:26:53
检查是否定义了.highlight CSS类,确保突出显示的文本实际得到高亮:)
当使用服务器端处理时,每次重绘表时都必须调用highlight。将此添加到您的dataTables初始化中:
..
fnDrawCallback : function() {
$('#cluster_dataTables td:nth-child(2)').highlight('internet'); //table test
$('#cluster_dataTables th:nth-child(2)').highlight('browser'); //head test
}看这个演示-> http://jsfiddle.net/r0nn8orv/ -试着点击页面。我已经在示例中包含了tabletools,尽管OP中对tabletools的关注只混淆了:)
https://stackoverflow.com/questions/25676716
复制相似问题