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 a 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 use gridview, I get the following result
Id Country State 1 India State 1 4 USA USA State1
Please provide solutions to fix this problem.
source share