Open timgws opened 9 years ago
Actually, never mind, it's because I should have used setDistinctCountGroup
...
I will leave this open, because I think we should clarify the usage for 5.0.
For future reference, this is how I was using the datatable, along with QueryBuilderParser.
<?php
class ItemController extends Controller
{
public function get_Datatable(Request $userRequest, ItemQueryRespository $iqr, $batch_id = 1)
{
if (!Datatable::shouldHandle()) {
return View::make('datatable');
}
$userRequest->canAccessBatch($batch_id);
//get filters
$post = Input::All();
if (isset($post['rules'])) {
$query = $iqr->build($post['rules']);
} else {
/**
* Default rules when nothing was posted from the QueryBuilderParser
*/
$query = $iqr->build()
->where('active', 1)
->where('visible', 1);
}
$query = $query->where('batch_id', '=', 1);
if (isset($post['groupByVendor']) && $post['groupByVendor'] == 'true') {
$query->groupBy('item_vendor');
}
//return the datatable result
$columns = array(
'item_name', 'item_description', 'item_vendor'
);
return Datatable::query($query)
->showColumns(array_merge(array('id'), $columns))
->searchColumns($columns)
->orderColumns($columns)
->setDistinctCountGroup()
->make();
}
}
There are three things wrong with this image after
->setNoGroupByOnCount()
was set on theDatatable::query
:group by
is not run.filtered by
should be the amount of entries (see # 1)Group By
is run, only 20 items are returned by the query, which means there are a handful of data-table pages that have empty rows.This is on the
master
branch on a Laravel 4.0 codebase.