"Panel table with filters (per column)"
Bootstrap 2.3.2 Snippet by xrozix

<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/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">ACTIVITY LIST</H3> <DIV CLASS="PULL-RIGHT"> <BUTTON CLASS="BTN BTN-DEFAULT BTN-XS BTN-FILTER"><SPAN CLASS="GLYPHICON GLYPHICON-FILTER"></SPAN> FILTER</BUTTON> </DIV> </DIV> <TABLE CLASS="TABLE"> <THEAD> <TR CLASS="FILTERS"> <TH><INPUT TYPE="TEXT" CLASS="FORM-CONTROL" PLACEHOLDER="#" DISABLED></TH> <TH><INPUT TYPE="TEXT" CLASS="FORM-CONTROL" PLACEHOLDER="ACTIVITY NAME" DISABLED></TH> <TH><INPUT TYPE="TEXT" CLASS="FORM-CONTROL" PLACEHOLDER="ASSOCIATED MILESTONE" DISABLED></TH> <TH><INPUT TYPE="TEXT" CLASS="FORM-CONTROL" PLACEHOLDER="OWNER" DISABLED></TH> </TR> </THEAD> <TBODY> <TR> <TD>1</TD> <TD>ACTIVITY-1</TD> <TD>MILESTONE-1</TD> <TD>OWNER-1</TD> </TR> <TR> <TD>2</TD> <TD>JACOB</TD> <TD>THORNTON</TD> <TD>@FAT</TD> </TR> <TR> <TD>3</TD> <TD>LARRY</TD> <TD>THE BIRD</TD> <TD>@TWITTER</TD> </TR> </TBODY> </TABLE> </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; }
/* 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'), $filters = $panel.find('.filters input'), $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), inputContent = $input.val().toLowerCase(), $panel = $input.parents('.filterable'), column = $panel.find('.filters th').index($input.parents('th')), $table = $panel.find('.table'), $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: