2017-09-23 41 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>