JQuery数据表+;jquery.highlight
遇到一些麻烦,希望有人能帮我指明方向。因为我是一个新手,所以我把剧本分出来帮助自己。我试图根据字段的值突出显示某些行中的某些值 我无法让它突出显示表中的实际字段,只有标题。这可能是服务器端处理的问题,或者可能是在填充表之前运行突出显示脚本的问题 数据表下载按钮集成脚本:JQuery数据表+;jquery.highlight,jquery,datatables,jquery-datatables,highlight,highlighting,Jquery,Datatables,Jquery Datatables,Highlight,Highlighting,遇到一些麻烦,希望有人能帮我指明方向。因为我是一个新手,所以我把剧本分出来帮助自己。我试图根据字段的值突出显示某些行中的某些值 我无法让它突出显示表中的实际字段,只有标题。这可能是服务器端处理的问题,或者可能是在填充表之前运行突出显示脚本的问题 数据表下载按钮集成脚本: <script> TableTools.BUTTONS.download = { "sAction": "text", "sTag": "default", "sFieldBoundary": "", "sField
<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>
TableTools.BUTTONS.download={
“sAction”:“text”,
“sTag”:“默认值”,
“sFieldBoundary”:“,
“sFieldSeperator”:“\t”,
“sNewLine”:“
”,
“走狗”:“走狗”,
“sButtonClass”:“DTTT_按钮_文本”,
“sButtonClassHover”:“DTTT按钮文本悬停”,
“sbuttonext”:“下载”,
“McColumns”:“所有”,
“bHeader”:没错,
“bFooter”:没错,
“sDiv”:“,
“fnMouseover”:空,
“fnMouseout”:空,
“fnClick”:功能(N按钮、oConfig){
var oParams=本s.dt.oApi.\u fNAJAX参数(本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”:空,
“fnplete”:空,
“fnInit”:空
};
用于填充表的脚本:
<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>
$(“#集群_数据表”)。数据表({
“bprocessing”:正确,
“bserverSide”:正确,
“sAjaxSource”:“./scripts/data.php”,
“sDom”:“Tlfrtip”,
“可旋转工具”:{
“阿布顿”:[{
“下载”,
“sButtonText”:“下载CSV”,
“sUrl”:“./scripts/data_csv.php”
}]
},
} );
执行突出显示的脚本:
<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>
$(“#cluster_dataTables td:nth child(2)”。突出显示('True')//表测试
$(“#集群_数据表th:n子(2)”。突出显示('Enabled')//头部试验
检查是否定义了.highlight
CSS类,确保突出显示的文本实际高亮显示:)
使用服务器端处理时,每次重新绘制表时,必须调用highlight
。例如,将此添加到数据表初始化中:
..
fnDrawCallback : function() {
$('#cluster_dataTables td:nth-child(2)').highlight('internet'); //table test
$('#cluster_dataTables th:nth-child(2)').highlight('browser'); //head test
}
查看此演示->-尝试单击页面。我在示例中包括了tabletools,尽管OP和答案中对tabletools的关注只会让人困惑:)