Girl Cerca:yii2 GridView non mostrando tutta la sinistra si uniscono i valori utilizzando hasMany retionship
$query = Countries::find()->joinWith(['states']);
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$dataProvider->setSort([
'defaultOrder' => ['doc_date'=>SORT_DESC],
]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
Modello:
public function getStates()
{
return $this->hasMany(States::className(), ['state_id' => 'state_id']);
}
devo comportare come
Id Country State
1 India State 1
2 India State 2
3 India State 3
4 USA USA State1
5 USA USA State2
Quando sto usando gridview Sto ottenendo il seguente risultato
Id Country State
1 India State 1
4 USA USA State1
Si prega di fornire soluzioni per risolvere questo problema.