couldn't make datatables work
sachittandukar opened this issue · comments
I'm trying to work on datatables bundle but failed to do so.
I'm only getting data:
{"sEcho":0,"iTotalRecords":1,"iTotalDisplayRecords":1,"aaData":[[1,"safasf","2013-02-04 00:00:00"]]}
While inspecting on console:
I'm getting this messages: Uncaught TypeError: Cannot read property 'asSorting' of undefined
here's my method in controller:
public function action_list() {
$users = User::select( array( 'users.id', 'users.username', 'users.created_at' ) );
return View::make( 'user.list',
array(
'test' => Datatables::of( $users )->make(),
)
);
}
here's my view:
{{ $test }}
<script src="/js/jquery.js"></script> <script src="/js/jquery.dataTables.js"></script> <script> (function($){ $('.hello').html( 'Can you help me in this error?? I don't know how to work with datatables :(
I guess, you don't have created table healthy. Try like this:
<table class="mws-datatable-fn mws-table">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
<th>Column 4</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
I would recommend to look at this example.
Sorry for old code issue but I followed the above and can get my table to render but with no data.
{{ $test }}
provides:
{"sEcho":0,"iTotalRecords":"23","iTotalDisplayRecords":"23","aaData":[["1","username","2013-02-07 10:49:20"],["2","
Any ideas?