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

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -