2017-09-23 63 views
0

我有一個Laravel項目,其中userlist.blade.php我有它顯示用戶列表哪些工作正常,但我用select字段來限制分頁不同的價值和Nitish庫馬爾在這裏在Stackoverflow我能夠從選擇字段中選擇的值,但我試圖知道如何我可以得到的值來影響當前的分頁,但我不明白如何工作也是我用過的循環索引顯示用戶增量編號不能很好地與分頁,所以我真的需要幫助在這裏瞭解如何工作。請 ?Ajax調用效果Laravel查看分頁

userlist.blade.php https://codeshare.io/2KoB4X

UsersController https://codeshare.io/G8rzjB

的script.js https://codeshare.io/5o0pWM

路線 https://codeshare.io/a3opmm

編輯1: 我正在尋找在下面的鏈接有數據表,您可以選擇的條目顯示錶中的編號 https://adminlte.io/themes/AdminLTE/pages/tables/data.html

+0

問題尋求幫助調試(「爲什麼不是這個代碼的工作?」)必須包括所期望的行爲,一個特定的問題或錯誤和**最短的代碼要重現它在問題本身* *。 – apokryfos

+0

我建議使用[Yajra Datatable包](https://datatables.yajrabox.com/),它允許您在服務器端處理中使用[jQuery datatble](https://datatables.net/)。它將解決動態分頁問題,​​並會在用戶列表中添加更多功能。 –

+0

@apokryfos我的問題是如何控制分頁使用select來顯示有限數量的用戶在表中的頁面。 –

回答

0

顯示結果這是當前的代碼,我

一個例子

$(document).ready(function() { 
 
    $('#issueinput5').on('change', function() { 
 
    $.ajax({ 
 
     url:'/lists/user', 
 
     method:'POST', 
 
     headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, 
 
     data:{'pageinateData':$('#issueinput5').val(),}, 
 
     success:function(d){ 
 
      console.log(d) 
 
     } 
 
    }); 
 
    }); 
 
});
<div class="form-group col-md-5"> 
 
    <div class="col-md-1">Show</div> 
 
    <div class="col-md-2"><select id="issueinput5" name="priority" class="form-control" 
 
    data-toggle="tooltip" data-trigger="hover" data-placement="top" data-title="Priority"> 
 
\t \t \t \t <option value="1">1</option> 
 
\t \t \t \t \t <option value="2">2</option> 
 
\t \t \t \t \t <option value="3">3</option> 
 
    </select></div> 
 
    <div class="col-md-1">entries</div> 
 
</div> 
 
<div class="table-responsive pl-1 pr-1"> 
 
    <table class="table table-bordered mb-0"> 
 
     <thead> 
 
      <tr> 
 
       <th>#</th> 
 
       <th>Full Name</th> 
 
       <th>Username</th> 
 
       <th>Email</th> 
 
       <th>User Type</th> 
 
       <th>Actions</th> 
 
      </tr> 
 
     </thead> 
 
     <tbody> 
 
      @foreach ($users as $user) 
 
      <tr> 
 
       <th scope="row">{{ $loop->index + 1 }}</th> 
 
       <td>{{ $user->fullname }}</td> 
 
       <td>{{ $user->username }}</td> 
 
       <td>{{ $user->email }}</td> 
 
       <td> 
 
        @foreach($roles as $role) {{ $user->role_id == $role->id ? $role->name : ''}}       @endforeach 
 
       </td> 
 
       <td> 
 
        <a href="{{ route('dUseInfo', [$user->id]) }}"><button type="button" 
 
        class="btn mr-0 mb-0 btn-outline-primary btn-sm"><i class="icon-settings2"></i>       </button></a> 
 
        <button type="button" class="btn mr-0 mb-0 btn-outline-primary btn-sm" 
 
        data-toggle="modal" data-target="#iconModal" data-user-id="{{ $user->id }}"> 
 
        <i class="icon-trash3"></i></button> 
 
       </td> 
 
      </tr> 
 
      @endforeach 
 
     </tbody> 
 
    </table> 
 
</div>