我是 Laravel 的新手,我正在尝试使用Yajra Datatable具有服务器端功能的插件。该插件适用于少量记录,但我有大量约 100000 条记录。
为了加快控制器中的进程,我使用 take(10) 限制查询的结果,并使用另一个查询来计算总结果。到目前为止一切都很好。
问题是如何管理研究。除了主要的研究领域,我还使用了单独的列搜索,但我不知道如何返回正确的记录数以使用单独的搜索过滤器管理分页。
我认为个人搜索键在$columns = $request->get('columns');但我不知道如何管理计数的查询。
感谢您的宝贵建议。
HTML 查看代码:
<table id="oTable">
<thead>
<tr>
<th>Action</th>
<th>Brand</th>
<th>Code</th>
<th>Description</th>
</tr>
<tr>
<th class="no_search"></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
</table>
Run Code Online (Sandbox Code Playgroud)
查询代码:
$('#oTable').DataTable({
dom: 'lfrtip',
"processing": true,
"serverSide": true,
"ajax": '{!! url('getRecords') !!}',
"columns": [
{data: 'items.id', name: 'items_id'},
{data: 'brands.description', name: 'brands_description'},
{data: 'items.code', name: 'items_code'},
{data: 'items.description', name: 'items_description'}
],
columnDefs: [
{targets: 'no_sort', orderable: false}
],
initComplete: function …Run Code Online (Sandbox Code Playgroud)