-
-
Save firecentaur/7578713 to your computer and use it in GitHub Desktop.
$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; | |
} |
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider' => $model->search(),
'id'=>'order-grid',
'columns'=>array(
array(
'header' => 'Word',
'name'=> 'Word',
'value' => $data->lemma
),
array(
'header' => 'Definition',
'value' => '"testtest"',
),
)
));
Turns out I didnt need to try to provide a value for those fields, I just needed to write in their names and gridview took care of the rest - thanks a mill for all your help - please add me on LinkedIn
http://www.linkedin.com/pub/paul-preibisch/4/130/a64
Ill give you a nice endorsement
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider' => $model->search(),
'id'=>'order-grid',
'columns' =>array(
array(
'name'=>'lemma',
"header"=>"Word"
),
'definition',
'wordid',
'synsetid',
array(
'header'=>"Action",
'name'=>'action'
)
)
));
$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'
)
My controller is :
public function actionSearch()
{
if (isset($_GET["SearchSynsetsModel"]["searchTerm"])){
$searchTerm=$_GET["SearchSynsetsModel"]["searchTerm"];
$model=new SearchSynsetsModel();
$lemma =Lemmatizer::lemmatize($searchTerm);
$model->searchTerm=$lemma;
$dataProvider = $model->search();
$model = new SearchSynsetsModel();
$model->searchTerm=$searchTerm;
$this->render('searchResultsView',
array(
'dataProvider'=>$dataProvider,
'model'=>$model,