如何在Laravel 4上使用Chumper的數據表添加類或ID,這樣我就可以在其上添加CSS和JS,我嘗試搜索網絡,但是沒有一個給出我直接的答案。如何在跳線數據表上添加類或ID?
這裏是我的(工作)代碼:
public function getSales()
{
$sales = DB::table('tblsaleshistory')
->select('ordered_by',DB::raw('sum(salesTotal) as st, count(ordered_by) as sell'))
->groupBy('ordered_by');
return Datatable::query($sales)
->addColumn('Name',function($model)
{
$html = $model->ordered_by;
return $html;
})
->addColumn('data',function($model)
{
$salesTotal = $model->st;
return $salesTotal;
})
->addColumn('%',function($model)
{
$percentage = "<span id='pa-".$model->ordered_by."'>".($model->st/5000)*100 ."</span>";
return $percentage;
})
->addColumn('sell',function($model)
{
$sell = $model->sell;
return $sell;
})
->searchColumns(array('ordered_by','sell','st'))
->orderColumns('st')
->make();
}
在我看來:
{{ HTML::script('js/dataTable/jquery.datatable.js') }}
<?php echo HTML::flash(); ?>
{{ Datatable::table()
->addColumn('PA','Total Sales','%','Sales Count') // these are the column headings to be shown
->setUrl('api/getSales') // this is the route where data will be retrieved
->render();
}}