JQGrid with Yii2

Hi,

I just wanted how you set this up with the application.

I have got everything working up to the point where the grid shows, but no data is showing. What is confusing me is where is the data supposed to come from? Can I have Jqgrid read directly from my model, or should it only read from a Json object?

Please see below code in the my main view.





<?= JqGridWidget::widget([

    'requestUrl' => 'admin/jqgrid',

    'gridSettings' => [

        'colNames' => ['ID', 'Firstname', 'Surname', 'DOB', 'Age', 'Date'],

        'colModel' => [

            ['name' => 'ID', 'index' => 'ID', 'editable' => true],

            ['name' => 'Firstname', 'index' => 'Firstname', 'editable' => true],

            ['name' => 'Surname', 'index' => 'Surname', 'editable' => true],

            ['name' => 'DOB', 'index' => 'DOB', 'editable' => true],

            ['name' => 'Age', 'index' => 'Age', 'editable' => true],

            ['name' => 'Date', 'index' => 'Date', 'editable' => true]

        ],

        'rowNum' => 15,

        'autowidth' => true,

        'height' => 'auto',

    ],

    'pagerSettings' => [

        'edit' => true,

        'add' => true,

        'del' => true,

        'search' => ['multipleSearch' => true]

    ],

    'enableFilterToolbar' => true

]);


?>




For example, how do I set it up to read directly from the database located in phpmyadmin on my local server? Does the request URL HAVE to linked to a JSON file?

Please let me know if you need any more information.

Note: there is nothing in my Controller as in the JQGrid extension page, it states it is optional.

Kind Regards

Hi, as you show in example https://github.com/himiklab/yii2-jqgrid-widget

you have to create action in your controller, and in this action you can pass model.