特定の TH の背景色を設定しようとしていますが、DataTables の設定でこれを行う簡単な方法が見つかりませんでした。テーブルの開始タグと終了タグのみを使用します。残りは DataTables で。
<table id="myTable"></table>
<script type="text/javascript">
$(document).ready(function(){
oTable = $("#myTable").dataTable({
"aaData" : myTableJsonData, //Working perfect
"bProcessing" : true,
"bJQueryUI" : true,
"sDom" : "<'H'f>rt<'F'i>",
"aoColumnDefs" : [
{ "aTargets":[0], "mDataProp":"id", "sTitle":"ID" },
{ "aTargets":[1], "mDataProp":"name", "sTitle":"NAME", "sClass":"name" },
{ "aTargets":[2], "mDataProp":"city", "sTitle":"CITY" }
]
});
});
</script>
すべての TD を変更したくないため、属性「sClass」は私の場合には適合しません。TH のみです。私は次のような簡単なことを試しました:
// Not work because looks like it is overwritten by jquery UI theme
$("#myTable").closest("thead").find(".name").addClass("bgGreen");
このようなものを設定すると、正常に動作します..しかし、それを避けたかったのです。
<table id="myTable">
<thead>
<tr>
<th></th>
<th class="bgGreen"></th>
<th></th>
</tr>
</thead>
</table>
助けてくれてありがとう!!