"Panel table with filters (per column)"
Bootstrap 3.1.0 Snippet by FriskyLingo

<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="row"> <div class="panel panel-primary filterable"> <div class="panel-heading"> <h3 class="panel-title">Jello Shot Jockeys</h3> <div class="pull-right"> <button class="btn btn-default btn-xs btn-filter"> <span class="glyphicon glyphicon-filter"></span> Filter </button> </div> </div> <div class="table-responsive"> <table class="table table-striped"> <thead> <tr class="filters"> <th class="col-md-1"><input type="text" class="form-control" placeholder="Date" disabled></th> <th class="col-md-1"><input type="text" class="form-control" placeholder="Time" disabled></th> <th class="col-md-1"><input type="text" class="form-control" placeholder="Field" disabled></th> <th><input type="text" class="form-control" placeholder="Home Team" disabled></th> <th><input type="text" class="form-control" placeholder="Away Team" disabled></th> <th><input type="text" class="form-control" placeholder="Umpire" disabled></th> <th><input type="text" class="form-control" placeholder="Home Score" disabled></th> <th><input type="text" class="form-control" placeholder="Away Score" disabled></th> </tr> </thead> <tbody> <tr class="text-nowrap"> <td>3/8/2015</td> <td>1:15 PM</td> <td>Field 7</td> <td class="long">Commingles</td> <td class="long">Jello Shot Jockeys</td> <td class="medium">Girls Just Wanna Have Rum</td> <td>11</td> <td>7</td> </tr> <tr class="text-nowrap"> <td>3/15/2015</td> <td>6:15 PM</td> <td>Field 1</td> <td class="long">Jello Shot Jockeys</td> <td class="long">Menace To Sobriety</td> <td class="medium">Blood, Sweat & Beers</td> <td>3</td> <td>5</td> </tr> </tbody> </table> </div> </div> </div> </div>
.filterable { margin-top: 15px; } .filterable .panel-heading .pull-right { margin-top: -20px; } .filterable .filters input[disabled] { background-color: transparent; border: none; cursor: auto; box-shadow: none; padding: 0; height: auto; } .filterable .filters input[disabled]::-webkit-input-placeholder { color: #333; } .filterable .filters input[disabled]::-moz-placeholder { color: #333; } .filterable .filters input[disabled]:-ms-input-placeholder { color: #333; } .text-nowrap td.short { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; } .text-nowrap td.medium { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; } .text-nowrap td.long { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 250px; }
/* Please consider that the JS part isn't production ready at all, I just code it to show the concept of merging filters and titles together ! */ $(document).ready(function(){ $('.filterable .btn-filter').click(function(){ var $panel = $(this).parents('.filterable'); var $filters = $panel.find('.filters input'); var $tbody = $panel.find('.table tbody'); if ($filters.prop('disabled') == true) { $filters.prop('disabled', false); $filters.first().focus(); } else { $filters.val('').prop('disabled', true); $tbody.find('.no-result').remove(); $tbody.find('tr').show(); } }); $('.filterable .filters input').keyup(function(e){ /* Ignore tab key */ var code = e.keyCode || e.which; if (code == '9') return; /* Useful DOM data and selectors */ var $input = $(this); var inputContent = $input.val().toLowerCase(); var $panel = $input.parents('.filterable'); var column = $panel.find('.filters th').index($input.parents('th')); var $table = $panel.find('.table'); var $rows = $table.find('tbody tr'); /* Dirtiest filter function ever ;) */ var $filteredRows = $rows.filter(function(){ var value = $(this).find('td').eq(column).text().toLowerCase(); return value.indexOf(inputContent) === -1; }); /* Clean previous no-result if exist */ $table.find('tbody .no-result').remove(); /* Show all rows, hide filtered ones (never do that outside of a demo ! xD) */ $rows.show(); $filteredRows.hide(); /* Prepend no-result row if all rows are filtered */ if ($filteredRows.length === $rows.length) { $table.find('tbody') .prepend($('<tr class="no-result text-center"><td colspan="'+ $table.find('.filters th').length +'">No result found</td></tr>')); } }); });

Related: See More


Questions / Comments: