GridView render problem

Hi, I’m a newbie in the Yii world and I have already faced a problem following the Yii tour.

When trying to display the data from a DB using the GridView widget, I get a terrible formatted output. Attached you can find the screenshot.

My controller code:


class SensorsDataController extends Controller {

	

	function actionIndex(){

		

		$query = SensorsData::find();

		

		$pagination = new Pagination([

			'defaultPageSize' => 12,

			'totalCount' => $query->count(),

			]);

			

		$provider = new ActiveDataProvider([

			'query'=>$query,

			'pagination'=>$pagination,

		]);

		

		return GridView::widget([

    		'dataProvider' => $provider,

    		'columns'=>[

    			'node',

    			'sensor',

    			'value',

    			'timestamp:date',

    		]

    	]);

	}	

}

What am I doing wrong? Thank you in advance.

Use GridView inside the view that you render from the controller’s action like here:

http://www.yiiframework.com/wiki/772/pjax-on-activeform-and-gridview-yii2/

http://www.bsourcecode.com/yiiframework2/gridview-in-yiiframework-2-0/