Created
September 4, 2018 13:32
-
-
Save sky-joker/4c013f689d1b44c51ce7eb3bf718cafb to your computer and use it in GitHub Desktop.
Bootstrapのテーブルサンプルにフィルタリングを実装したメモ ref: https://bootsnipp.com/snippets/featured/table-panel-with-pagination
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> | |
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script> | |
<!------ Include the above in your HEAD tag ----------> | |
<script> | |
$(document).ready(function(){ | |
$("#myInput").on("keyup", function() { | |
var value = $(this).val().toLowerCase(); | |
$("#myTable tr").filter(function() { | |
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1) | |
}); | |
}); | |
}); | |
</script> | |
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css" rel='stylesheet' type='text/css'> | |
<div class="container"> | |
<div class="row"> | |
<p></p> | |
<h1>Bootstrap Table Panel with Pagination</h1> | |
<p>A simple example of how-to put a bordered table within a panel. Responsive, place holders in header/footer for buttons or pagination.</p> | |
<p>Follow me <a href="https://twitter.com/asked_io" target="_new">@asked_io</a> & <a href="https://asked.io/" target="_new">asked.io</a>.</p> | |
<p> </p><p> </p> | |
<div class="col-md-10 col-md-offset-1"> | |
<div class="panel panel-default panel-table"> | |
<div class="panel-heading"> | |
<div class="row"> | |
<div class="col col-xs-6"> | |
<h3 class="panel-title">Panel Heading</h3> | |
</div> | |
<div class="col col-xs-6 text-right"> | |
<input class="form-control" id="myInput" type="text" placeholder="Search.."> | |
</div> | |
</div> | |
</div> | |
<div class="panel-body"> | |
<table class="table table-striped table-bordered table-list"> | |
<thead> | |
<tr> | |
<th><em class="fa fa-cog"></em></th> | |
<th class="hidden-xs">ID</th> | |
<th>Name</th> | |
<th>Email</th> | |
</tr> | |
</thead> | |
<tbody id="myTable"> | |
<tr> | |
<td align="center"> | |
<a class="btn btn-default"><em class="fa fa-pencil"></em></a> | |
<a class="btn btn-danger"><em class="fa fa-trash"></em></a> | |
</td> | |
<td class="hidden-xs">1</td> | |
<td>John Doe</td> | |
<td>johndoe@example.com</td> | |
</tr> | |
<tr> | |
<td align="center"> | |
<a class="btn btn-default"><em class="fa fa-pencil"></em></a> | |
<a class="btn btn-danger"><em class="fa fa-trash"></em></a> | |
</td> | |
<td class="hidden-xs">1</td> | |
<td>bob</td> | |
<td>bob@example.com</td> | |
</tr> | |
</tbody> | |
</table> | |
</div> | |
<div class="panel-footer"> | |
<div class="row"> | |
<div class="col col-xs-4">Page 1 of 5 | |
</div> | |
<div class="col col-xs-8"> | |
<ul class="pagination hidden-xs pull-right"> | |
<li><a href="#">1</a></li> | |
<li><a href="#">2</a></li> | |
<li><a href="#">3</a></li> | |
<li><a href="#">4</a></li> | |
<li><a href="#">5</a></li> | |
</ul> | |
<ul class="pagination visible-xs pull-right"> | |
<li><a href="#">«</a></li> | |
<li><a href="#">»</a></li> | |
</ul> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div></div></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment