Model Search :
$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;
}
Model :
public function getStates()
{
return $this->hasMany(States::className(), ['state_id' => 'state_id']);
}
I need result like
Id Country State
1 India State 1
2 India State 2
3 India State 3
4 USA USA State1
5 USA USA State2
When I'm using gridview I'm getting following result
Id Country State
1 India State 1
4 USA USA State1
Please give solutions to fix this issue.