Grid View

how can i create a grid view from a model displaying only records with the given ids?

When I understand your question correct you want to display not ALL but some specific records in a GridView?

Then You don’t have to modify the GridView.

Just create a DataProvider containing the model records you want.


Short Example (scroll to GridView):


thank you!

something like… in Yii1.1

$criteria = new CDbCriteria();

$criteria->addInCondition("id", array(6,7,8,9));

Just to avoid confusion:

As far as I know there is no CDbCriteria in YII 2 anymore.

You now use yii\db\Query or yii\db\ActiveQuery

See following topics for reference:


yes it was in Yii1.1