Yii2 Group by and display relational data in a list view

I’ve written a very simple blog and I want to display the entries in a list view grouped by category.

In my KnowledgeCategory model I have

public function getKnowledgeItems()
            return $this->hasMany(KnowledgeItem::className(), ['category_id' => 'id']);

In my KnowledgeItem model I have

public function getCategory()
    return $this->hasOne(KnowledgeCategory::className(), ['id' => 'category_id']);

In my index.php

<div class="knowledge-item-index">

<h1><?= Html::encode($this->title) ?></h1>
<?php echo $this->render('_search', ['model' => $searchModel]); ?>

    <?= Html::a('Create Knowledge Item', ['create'], ['class' => 'btn btn-success']) ?>

    <?= Html::a('Create Category', ['knowledge-category/create'], ['class' => 'btn btn-success']) ?>

<?= \yii\widgets\ListView::widget([
    'dataProvider' => $dataProvider,
    'viewParams' => ['category'=>'xxx'],
    'itemView' => '_item',
   'layout' => '<div class="row">{items}</div><div class="text-center">{pager}</div>',
   // 'filterModel' => $searchModel,


in _item.php


use yii\helpers\Html;
use yii\helpers\Url;


<?= Html::a ($model->title, ['knowledge/view', 'id'=>$model->id])?>


What am I missing?

How do you construct the dataProvider?