Я использую laravel 5. Я отобразил данные из базы данных в таблицах:
<table class="table table-striped table-bordered" id="mytable" >
<thead>
<tr>
<td><strong>#</strong></td>
<td class="text-center col-lg-1"><strong>Seksyen</strong></td>
<td class="text-center col-lg-3"><strong>Kategori</strong></td>
<td class="text-center col-lg3-2"><strong>Pangkat</strong></td>
<td class="text-center col-lg-5"><strong>Nama</strong></td>
<td class="text-center col-lg-1"><strong>No Personal</strong></td>
<td class="text-center"><strong>Lihat Rekod</strong></td>
<td class="text-center"><strong>Edit</strong></td>
</tr>
</thead>
<tbody>
@foreach($itemregistrations as $index => $value)
<tr>
<td>{{ $index+1 }}</td>
<td>{{ $value->sectionname }}</td>
<td>{{ $value->categoryname }}</td>
<td>{{ $value->operasiname }}</td>
<td>{{ $value->name }}</td>
<td>{{ $value->Nobadan }}</td>
<td class="text-center">
<a href="{{ route('viewProfil',$value->ItemRegistrationID) }}"><i class="fa fa-folder fa-fw" rel="tooltip" title="view profil"></i></a></td>
@can('Edit Pegawai','Edit APR','Edit KTA','Edit PTK')
<td class="text-center"><a href="{{ route('editProfil',$value->ItemRegistrationID) }}"><i class="fa fa-pencil fa-fw" rel="tooltip" title="edit profil"></i></a></td>
@endcan
</tr>
@endforeach
</tbody>
</table>
<ul class="pagination pull-right">
{{ $itemregistrations->links() }}
</ul>
Вывод html:
<table class="table table-striped table-bordered" id="mytable">
<thead>
<tr>
<td><strong>#</strong></td>
<td class="text-center col-lg-1"><strong>Seksyen</strong></td>
<td class="text-center col-lg-3"><strong>Kategori</strong></td>
<td class="text-center col-lg3-2"><strong>Pangkat</strong></td>
<td class="text-center col-lg-5"><strong>Nama</strong></td>
<td class="text-center col-lg-1"><strong>No Personal</strong></td>
<td class="text-center"><strong>Lihat Rekod</strong></td>
<td class="text-center"><strong>Edit</strong></td>
</tr>
</thead>
<tbody>
<tr style="display: table-row;">
<td>1</td>
<td>B8</td>
<td>KAKITANGAN</td>
<td>EXEC</td>
<td>AB SAUFI</td>
<td>I10111</td>
<td class="text-center"><a href="http://127.0.0.1:8000/view_profil/3"><i class="fa fa-folder fa-fw" rel="tooltip" title="" data-original-title="view profil"></i></a></td>
<td class="text-center"><a href="http://127.0.0.1:8000/edit_profil/3"><i class="fa fa-pencil fa-fw" rel="tooltip" title="" data-original-title="edit profil"></i></a></td>
</tr>
<tr style="display: table-row;">
<td>2</td>
<td>C4</td>
<td>KAKITANGAN</td>
<td>EXEC</td>
<td>ABBAS HALIM</td>
<td>I38222</td>
<td class="text-center"><a href="http://127.0.0.1:8000/view_profil/38"><i class="fa fa-folder fa-fw" rel="tooltip" title="" data-original-title="view profil"></i></a></td>
<td class="text-center"><a href="http://127.0.0.1:8000/edit_profil/38"><i class="fa fa-pencil fa-fw" rel="tooltip" title="" data-original-title="edit profil"></i></a></td>
</tr>
<tr style="display: table-row;">
<td>3</td>
<td>S2</td>
<td>KAKITANGAN</td>
<td>CLERK</td>
<td>LAILA GHANI</td>
<td>I9394</td>
<td class="text-center"><a href="http://127.0.0.1:8000/view_profil/41"><i class="fa fa-folder fa-fw" rel="tooltip" title="" data-original-title="view profil"></i></a></td>
<td class="text-center"><a href="http://127.0.0.1:8000/edit_profil/41"><i class="fa fa-pencil fa-fw" rel="tooltip" title="" data-original-title="edit profil"></i></a></td>
</tr>
<tr style="display: table-row;">
<td>4</td>
<td>S1</td>
<td>KAKITANGAN</td>
<td>CLERK</td>
<td>AWANG JALIL</td>
<td>I377635</td>
<td class="text-center"><a href="http://127.0.0.1:8000/view_profil/94"><i class="fa fa-folder fa-fw" rel="tooltip" title="" data-original-title="view profil"></i></a></td>
<td class="text-center"><a href="http://127.0.0.1:8000/edit_profil/94"><i class="fa fa-pencil fa-fw" rel="tooltip" title="" data-original-title="edit profil"></i></a></td>
</tr>
<tr style="display: table-row;">
<td>5</td>
<td>R3</td>
<td>KAKITANGAN</td>
<td>EXEC</td>
<td>HAWA HASSAN</td>
<td>I017017</td>
<td class="text-center"><a href="http://127.0.0.1:8000/view_profil/99"><i class="fa fa-folder fa-fw" rel="tooltip" title="" data-original-title="view profil"></i></a></td>
<td class="text-center"><a href="http://127.0.0.1:8000/edit_profil/99"><i class="fa fa-pencil fa-fw" rel="tooltip" title="" data-original-title="edit profil"></i></a></td>
</tr>
<tr style="display: table-row;">
<td>6</td>
<td>S1</td>
<td>KAKITANGAN</td>
<td>CHIEF</td>
<td>SHAHRIL KHALID</td>
<td>I217315</td>
<td class="text-center"><a href="http://127.0.0.1:8000/view_profil/108"><i class="fa fa-folder fa-fw" rel="tooltip" title="" data-original-title="view profil"></i></a></td>
<td class="text-center"><a href="http://127.0.0.1:8000/edit_profil/108"><i class="fa fa-pencil fa-fw" rel="tooltip" title="" data-original-title="edit profil"></i></a></td>
</tr>
<tr style="display: table-row;">
<td>7</td>
<td>S1</td>
<td>KAKITANGAN</td>
<td>EXEC</td>
<td>AZRI DAUD</td>
<td>I022772</td>
<td class="text-center"><a href="http://127.0.0.1:8000/view_profil/119"><i class="fa fa-folder fa-fw" rel="tooltip" title="" data-original-title="view profil"></i></a></td>
<td class="text-center"><a href="http://127.0.0.1:8000/edit_profil/119"><i class="fa fa-pencil fa-fw" rel="tooltip" title="" data-original-title="edit profil"></i></a></td>
</tr>
<tr style="display: table-row;">
<td>8</td>
<td>D2</td>
<td>KAKITANGAN</td>
<td>CHIEF</td>
<td>LOLA FARID</td>
<td>I015371</td>
<td class="text-center"><a href="http://127.0.0.1:8000/view_profil/132"><i class="fa fa-folder fa-fw" rel="tooltip" title="" data-original-title="view profil"></i></a></td>
<td class="text-center"><a href="http://127.0.0.1:8000/edit_profil/132"><i class="fa fa-pencil fa-fw" rel="tooltip" title="" data-original-title="edit profil"></i></a></td>
</tr>
<tr style="display: table-row;">
<td>9</td>
<td>A</td>
<td>KAKITANGAN</td>
<td>CHIEF</td>
<td>ALI AHMAD</td>
<td>I90111</td>
<td class="text-center"><a href="http://127.0.0.1:8000/view_profil/157"><i class="fa fa-folder fa-fw" rel="tooltip" title="" data-original-title="view profil"></i></a></td>
<td class="text-center"><a href="http://127.0.0.1:8000/edit_profil/157"><i class="fa fa-pencil fa-fw" rel="tooltip" title="" data-original-title="edit profil"></i></a></td>
</tr>
<tr style="display: table-row;">
<td>10</td>
<td>B6</td>
<td>KAKITANGAN</td>
<td>EXEC</td>
<td>HANI MUHAMMAD</td>
<td>I2881</td>
<td class="text-center"><a href="http://127.0.0.1:8000/view_profil/194"><i class="fa fa-folder fa-fw" rel="tooltip" title="" data-original-title="view profil"></i></a></td>
<td class="text-center"><a href="http://127.0.0.1:8000/edit_profil/194"><i class="fa fa-pencil fa-fw" rel="tooltip" title="" data-original-title="edit profil"></i></a></td>
</tr>
</tbody>
</table>
Я использовал скрипт jquery для поиска в html-таблице, например:это для выполнения функции фильтра:
<script>
// Write on keyup event of keyword input element
$(document).ready(function(){
$("#search").keyup(function(){
_this = this;
// Show only matching TR, hide rest of them
$.each($("#mytable tbody tr"), function() {
if($(this).text().toLowerCase().indexOf($(_this).val().toLowerCase()) === -1)
{
$(this).hide();
}
else
{
$(this).show();
}
});
});
});
</script>
Я должен был отобразить таблицы данных в пагинации.Поиск может сделать фильтр, но только то, что отображается на странице.Он не выполняет поиск по всем данным на других страницах нумерации страниц.
Как изменить код для поиска по всем страницам нумерации страниц?