如何让动态搜索不仅仅使用Laravel 5搜索第一页,而是全部?
Jquery的:
var $cells = $("tbody td");
$(".searchterm").keyup(function() {
var val = $.trim(this.value).toUpperCase();
if (val === "")
$cells.parent().show();
else {
$cells.parent().hide();
$cells.filter(function() {
return -1 != $(this).text().toUpperCase().indexOf(val); }).parent().show();
}
});
PHP:
public function index()
{
$ban = DB::table("bans")->select(['id', 'userid', 'banned_by', 'date_issued'])->orderBy("date_issued", "asc")->paginate(15);
return view("bans")->with('bans', $ban);
}
Web.php路线:
Route::get('bans', 'BanController@index');
答案 0 :(得分:0)
这是我的代码。我认为这有助于你。
function tableSearch() {
var input, filter, table, tr, td, i;
input = document.getElementById("txtSearch");
filter = input.value.toUpperCase();
style = '';
tr = $('#tbCustomer tbody tr');///table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td");
for (var j = 1; j < td.length; j++) {
if ($(td[j]).attr('style') != "display:none;") {
if (td[j]) {
if (tr[i].innerHTML.toUpperCase().indexOf(filter) > -1) {
style = 'table-row';
} else {
style = 'none';
//break;
}
}
}
}
$(tr[i]).css('display', style);
}
tr = $('#tbCustomer tbody tr:visible');
if (tr.length <= 0) {
var tdata = '';
var trow = '';
tdata = '<td colspan="11" class="text-center alert alert-warning">No data found !</td>';
trow = '<tr data-id="0001">' + tdata + '</tr>'
$('#tbCustomer tbody ').append(trow);
$('#tbCustomer tfoot ').hide();
}
pagination($('#tbCustomer tbody tr:visible'));
}