mardi 8 mars 2016

Datatable - Server side data is not displaying

I am playing with datatable with Laravel 5 with first time so I tried with this code and I am getting data on ajax but not able to display data on my datatable.

Any Idea how to load response data to datatable.

Here is my structure:

Result:

enter image description here

Route:

Route::get('admin/pages/datatable', 'admin\PagesController@getDataTable'); // Pages (Static Pages)

pages.blade.php:

<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <h3 class="box-title">Pages Table</h3>
                </div><!-- /.box-header -->
                <div class="box-body">
                    <table id="example32" class="table table-bordered table-hover">
                        <thead>
                            <tr>
                                <th>PageId</th>
                                <th>Title</th>
                                <th>Text</th>
                                <th>MetaKeywords</th>
                                <th>MetaDescription</th>
                                <th>PostedBy</th>
                            </tr>
                        </thead>
                        <tfoot>
                            <tr>
                                <th>PageId</th>
                                <th>Title</th>
                                <th>Text</th>
                                <th>MetaKeywords</th>
                                <th>MetaDescription</th>
                                <th>PostedBy</th>
                            </tr>
                        </tfoot>
                    </table>
                </div><!-- /.box-body -->
            </div><!-- /.box -->
        </div><!-- /.col -->
    </div><!-- /.row -->
</section><!-- /.content -->

PagesController.php:

public function getDataTable()
{
    $Pages = new Pages();
    return $GetAllPages = $Pages->GetPages();
}

Pages.php:

public function GetPages()
{
    return DB::table('pages')->select('PageId', 'Title', 'Text', 'MetaKeywords', 'MetaDescription', 'PostedBy')
            ->get();
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire