Rearranging datatable columns with javascript conditions.
Rearranging datatable columns with javascript conditions.
banasree
Posts: 1Questions: 1Answers: 0
Hi I am new to datatable. I am using server side datatable. my problem is I want the few columns to be rearranged based conditions of javascript. below is my code.
<script type="text/javascript">
var condition=$("#quarter").text();
var table= $('#storageTable').DataTable(
{ "bProcessing": true,
"bServerSide": true,
"sort": "position",
"bStateSave": false,
"iDisplayLength": 10,
"iDisplayStart": 0,
"bFilter": false,
"sAjaxSource": "getStorageDetails",
"aoColumns": [
{ "mData": "name"},
{ "mRender": function (data,full,type,meta) {
if(type.usedtablespacePct<50)
return "<div class='bar'>something</div>";
}
},
{ "mData": "q1" },
{ "mData": "q2" },
{ "mData": "q3" },
{ "mData": "q4" },
]
} );
</script>
The q1, q2 q3, q4 column should be rearranged depending on the value of the variable "quarter".
I do I do that? Please suggest
This discussion has been closed.