Yii uses CGridView
Add the following to the Controller:
?
| 1234567891011 |
PublicfunctionactionIndex () {$ model = newUser ('search'); $ model-> unsetAttributes (); // clear any default values if (isset ($ _ GET ['user']) $ model-> attributes = $ _ GET ['user']; $ this-> render ('admin', array ('model' => $ model ,));} |
Add the following to the Model:
?
| 1234567891011 |
Publicfunctionsearch () {$ criteria = newCDbCriteria; $ criteria-> compare ('username', $ this-> username, true); $ criteria-> compare ('email ', $ this-> email, true); returnnewCActiveDataProvider ($ this, array ('criteria '=> $ criteria ,));} |
Display in View:
?
| 1234567891011121314151617181920 |
Widget ('zii. widgets. grid. CGridView ', array ('id' => 'User-grid', 'dataprovider' => $ model-> search (), 'filter' => $ model, 'columns '=> array ('id', 'username', 'Email', array ('header' => 'ABC', 'value' => 'chtml :: link ("Link", Yii: app ()-> createUrl ("index") ', 'type' => 'raw ',), // add the link array ('class' => 'cbuttoncolumn',);?> |