Laravel 5 and Bootgrid Pagination -


i'm working laravel 5 , bootgrid pagination. i'm planning use later i'm learning , playing around can't make work. in browser console

uncaught typeerror: cannot read property 'length' of undefined 

i don't know if data format i'm passing.

here's html

<table id="grid-data" class="table table-condensed table-hover table-striped" data-toggle="bootgrid" data-ajax="true" data-url="api/deliverytracker">     <thead>         <tr>             <th data-column-id="id" data-identifier="true">id</th>             <th data-column-id="sender">sender</th>             <th data-column-id="received">recieved</th>         </tr>     </thead>     </table> 

in route api/deliverytracker

route::any('api/deliverytracker', 'deliverytrackercontroller@deliveryindexapi'); 

then function in deliverytrackercontroller

public function deliveryindexapi() {     $data = array(         array('id' => '1', 'sender' => '123@test.de', 'received' => '2014-05-30t22:15:00'),         array('id' => '2', 'sender' => '123@test.de', 'received' => '2014-05-30t22:15:00'),         );      return json_encode($data); } 

did missed something? tried console log $data turns out

[{"id":"1","sender":"123@test.de","received":"2014-05-30t22:15:00"},{"id":"2","sender":"123@test.de","received":"2014-05-30t22:15:00"}] 

thanks!

you need return json correctly .

$data = array(         "current" => 1,         "rowcount" => 10,         "rows" => array(          array('id' => '1', 'sender' => '123@test.de', 'received' => '2014-05-30t22:15:00'),          array('id' => '2', 'sender' => '123@test.de', 'received' => '2014-05-30t22:15:00')          ),         "total" => 1123        ); 

check official documentation http://www.jquery-bootgrid.com/examples#data


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -