【发布时间】:2015-04-16 06:56:07
【问题描述】:
我正在尝试使用 Chumper 数据表库在页面上显示表格。
我有我的发票模型
类发票扩展了 Eloquent { 受保护的 $table = '发票';
在我看来:
{{ Datatable::table()
->addColumn('id','client_id') // these are the column headings to be shown
->setUrl(route('api.invoices')) // this is the route where data will be retrieved
->render() }}
控制器
public function getDatatable()
{
return Datatable::collection(Invoice::all(array('id','client_id')))
->showColumns('id', 'client_id')
->searchColumns('client_id')
->orderColumns('id','client_id')
->make();
}
路线
Route::get('api/invoices', array('as'=>'api.invoices', 'uses'=>'InvoiceController@getDatatable'));
表头已显示,但下方没有数据。有什么想法吗?
在 Chrome 中这行代码也出现错误
oTable = jQuery('#CIZatgPm').dataTable({
Uncaught Type error: undefined is not a function
【问题讨论】:
-
那个 javascript 错误是说 dataTable 函数没有被定义。您是否在 HTML 中包含了 datatables javascript 库?
标签: javascript laravel datatable