Last active
December 28, 2015 23:28
-
-
Save firecentaur/7578713 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$this->widget('zii.widgets.grid.CGridView', array( | |
'dataProvider' => $dataProvider, | |
'id'=>'order-grid', | |
'columns'=>array( | |
array( | |
'header' => 'Word', | |
'name'=> 'Word', | |
'value' => $data->lemma | |
), | |
array( | |
'header' => 'Definition', | |
'value' => '"testtest"', | |
), | |
) | |
)); | |
---- | |
public function search() | |
{ | |
// @todo Please modify the following code to remove attributes that should not be searched. | |
$sql = 'select | |
words.lemma, | |
mepsynsets.definition, | |
mepsenses.wordid, | |
mepsynsets.synsetid | |
from mepsynsets | |
left join mepsenses on mepsynsets.synsetid = mepsenses.synsetid | |
left join words on mepsenses.wordid=words.wordid | |
where lemma=:lemma'; | |
$synsets=Yii::app()->db->createCommand($sql); | |
$synsets->bindParam(":lemma",$this->searchTerm); | |
$dataReader = $synsets->query(); | |
$count= $dataReader->rowCount; | |
$dataProvider=new CSqlDataProvider( | |
$sql,array( | |
'keyField'=>'synsetid', | |
'totalItemCount'=>$count, | |
//'totalItemCount'=>$count, | |
'params'=>array( | |
':lemma'=>$this->searchTerm, | |
), | |
'sort'=>array( | |
'attributes'=>array( | |
'definition', 'lemma','wordid','synsetid' | |
), | |
), | |
'pagination'=>array( | |
'pageSize'=>20 | |
) | |
)); | |
return $dataProvider; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider' => $model->search(),
'id'=>'order-grid',
'columns' =>array(
array(
'name'=>'Word',
'htmlOptions'=>array('style'=>'text-align:center; width:100px'),
'value'=>'$data->lemma',
),
'definition',
'wordid',
'synsetid',
array(
'header'=>"Action",
'name'=>'action'
)