Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vandan's avatar
Level 13

my database record display in metronic datatable?

i have metronic theme use so how can i my database data display(view) in datatable

so how to display data please help me

https://keenthemes.com/metronic/preview/demo6/crud/metronic-datatable/base/data-local.html

0 likes
4 replies
vandan's avatar
Level 13

here is my datatable.js file

data: {
            type: 'remote',
            source: {
                read: {
                    url: 'https://keenthemes.com/metronic/tools/preview/api/datatables/demos/client.php',
                },
            },

    columns: [
        {
                        field: "Name",
                        title: "Name",
                        width: 200,
                        // callback function support for column rendering
                        template: function (data, i) {
                            var number = 4 + i;
                             while (number > 12) {
                                    number = number - 3;
                            }
                            var user_img = '100_' + number + '.jpg';
                            var pos = KTUtil.getRandomInt(0, 5);
                            var position = [
                                 'Developer',
                                     'Designer',
                                     'CEO',
                                 'Manager',
                                 'Architect',
                                     'Sales'
                        ];

here is my controller file

public function view()
    {
        $view = Pg::all();        
        return view('admin.pages.pg.viewpg',compact('view'))->render();
    }

here is my route file

Route::get('Pg/View',array('as'=>'pg_view','uses'=>'Pages\PgController@view'));

how to pass json data controller to view or js file i dont understand

thinkverse's avatar

Don't think you need the link, looking at how the datatable.js from the example code above you need to change the read.url to one from your Laravel application. Mimicking the JSON structure returned from the demo seems like a way to start.

For that, you can use API Resources to transform the JSON response returns from your API.

Please or to participate in this conversation.