how can i apply smartsearch filter on when checkbox is checked otherwise not?
how can i apply smartsearch filter on when checkbox is checked otherwise not?
tejas3006
Posts: 5Questions: 1Answers: 0
My code look like this :
HTML CODE
<div id="mainContent">
<div class="row">
<div class="col-sm-11" style="margin-top:5px;margin-left:5px">
<div class="panel panel-default">
<div class="panel-heading"><center><b>Active Node</b></center></div>
<div class="panel-body">
<div class="col-sm-12">
<table class="col-sm-12">
<tbody>
<tr id="filter_global">
<td> <b> Smart Search :</b>
<input type="checkbox" id="smartSearch">
</td>
</tr>
</tbody>
</table>
</div>
<div class="col-sm-12">
<div class="table-responsive">
<table id="activeNodeList" class="table table-striped table-bordered table-hover text-center">
<thead>
<th><b><center>IP Address </center></b></th>
<th><b><center>Name </center></b></th>
<th><b><center>MAC Address</center></b></th>
<th><b><center>Serial</center></b></th>
<th><b><center>Uptime</center></b></th>
<th><b><center>Software Version</center></b></th>
<th><b><center>Temperature </center></b></th>
<th></th>
</thead>
<tbody id="myTable"></tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
Script :
<script type="text/javascript" src=@routes.Assets.at("javascripts/bootstrap/plugins/dataTables/jquery.dataTables.js")></script>
<script type="text/javascript" src=@routes.Assets.at("javascripts/bootstrap/plugins/dataTables/dataTables.search-highlight.js")></script>
<script type="text/javascript">
$(document).ready(function() {
json = (@Html(jsonData)).nodes;
while (node = json.pop()) {
$('#activeNodeList tbody').append("<tr><td>" + node.ip_address + "</td><td><a href='/nodeByIndex/" + node.index + "'>" + node.name + "</a></td><td>" + node.mac_address + "</td><td>" + node.sr_no + "</td><td>" + node.uptime + "</td><td>" + node.software_version + "</td><td>" + node.temperature + "° C</td><td><a href='/config/"+ node.ip_address +"' class='btn btn-outline btn-primary btn-xs' style='margin:0px;text-decoration:none'>" + "Configure" + "</a></td></tr>");
}
$(document).ready(function() {
$('#activeNodeList').dataTable();
});
$('input[type="checkbox"]').change(function(event) {
var isChecked = $('#smartSearch').is(':checked');
if (isChecked == false)
{
alert(isChecked);
$('#activeNodeList').dataTable ({
"search": {"smart": false}
"search": {"smart": false}
});
}
else
{
$('#activeNodeList').dataTable ({
"search": {"smart": true}
});
}
});
$('#activeNodeList').dataTable().fnSearchHighlighting();
} );
</script>
Here i want to do when my check box is checked then smartsearch will be on otherwise not. id for checkbox is "smartSearch".
Can you help me to do so ??
This discussion has been closed.
Answers
sorry for HTML CODE..actually it looks like this...
i have done..!!!