Listview widget working example

I am working on a project and I have decided to use yii 2 for it.

I need to use the ListView widget to display some items, however, I have noticed that there is no documentation for the ListView widget on the yii 2 api doc site: http://www.yiiframework.com/doc-2.0/guide-output-data-widgets.html

I have scoured google, stackoverflow etc and have not been able to find a complete example of using ListView widgets in Yii 2

I need a complete working example of using the ListView widget so that I can adapt same for my project

Will coin one once am at my Laptop

But if you look at Gridview you will have idea on LV

Thanks a lot Stefano. I am eagerly expecting your response. I have searched all over the net to no avail. Any code sample you provide will be highly appreciated




<?= ListView::widget([

    	'dataProvider' => $dataProvider,

    	'itemOptions' => ['class' => 'item'],

    	'itemView' => function ($model, $key, $index, $widget) {

        	return Html::a(Html::encode($model->name), ['view', 'id' => $model->id]);

    	},

]) ?>



As you see you can provide itemView as callable or as file as in


 'itemView' =>'_myView'

Thanks a lot. I will try this out! Much appreciated