Hi
I am trying to design my JQUERY DATATABLE for variable devices . So i want to hide some columns in my table . So for better Responsiveness and its advantages i choose BOOTSTRAP 3.0
Well i done everything but i am unable to FIND logic how to hide columns which are DYNAMICALLY generated under HEAD tags in my HTML table .
Here is my code for better understanding :
<script type="text/javascript">
$(document).ready(function () {
$('#myDataTable').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": 'DataProvider',
"bJQueryUI": true,
"aoColumns": [
{
"sName": "ID"
},
{ "sName": "COMPANY_NAME" },
{ "sName": "ADDRESS" },
{ "sName": "TOWN" }
]
});
});
</script>
}
<div class="table-responsive">
<table id="myDataTable" class="table">
<thead>
<tr>
<th>ID</th>
<th class="hidden-xs">Company name</th>
<th>Address</th>
<th>Town</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<style>
.table-responsive tr td:nth-child(2) {
visibility:hidden;
background: red;
position:absolute;
}
.table-responsive tr th:nth-child(2) {
visibility:hidden;
position:absolute;
background: white;
}
table#myDataTable tbody td:nth-child(2)
{
background: red;
}
</style>
CHROME INSPECT ELEMENT :
<tr class="odd" id="17">
<td class=" sorting_1">17</td>
<td class=""><a href="Home/Details/17">Emkay Entertainments</a></td>
<td class="">Nobel House, Regent Centre</td>
<td class="" title="Click to select town">Lothian</td>
</tr>
In the above code see you cant find the TD tags but when my code executes the plugin will get the data i.e under TH tags with respective TD's ..
What i tried : I know it wont work for TD'S STILL I tried so used css class hidden-xs on TH Tag when i reduce my browser size the TH tag is hiding but not the columns under it .
I NEED SUGGESTIONS TO HIDE 2ND OR WATEVER COLUMNS WHICH ARE DYNAMICALLY GENERATED . .
regards