Yii Grid Using Cformmodel


Is there a way on how I can create a grid using CFormModel, just like setting the items inside the grid from a SQL statement and can be sortable by using WHERE keyword?

No, it’s not I think. There are special classes which do exactly what you want.

Why do you want to do it this way ?

You can use CArrayDataProvider or CSqlDataProvider for your CGridView.

But IMHO you should not try them until you encounter a really complicated demand that you would find it difficult to handle with CActiveDataProvider. It’s quite sure that they will require you a lot more coding than CActiveDataProvider.

Thank You guys,

I have searched CSqlProvider and apply it in a sample program but when I try it I received an erro saying:

PHP notice

Undefined index: id


You can see my sample data here:


Thanks again.