Hi
I need help to make a CGridView with an edit in place function
I try several widgets (such as CEditableColumn, or Jeditable, or jqgrid) but it never works
My last try was with Jeditable widget
I want to extend CGridColumn to override the renderDataCellContent function
Here is my code : CJeditableColumn.php
Yii::import('zii.widgets.grid.CGridColumn');
/**
* CJEditableColumn represents a grid view column that is editable.
*/
class CJEditableColumn extends CGridColumn
{
public $name;
public $value;
/**
* Initializes the column.
*/
public function init()
{
parent::init();
//Yii::log("init : ".$this->name." ".$this->value,"debug","z");
if($this->name===null && $this->value===null)
throw new CException(Yii::t('zii','Either "name" or "value" must be specified for CJEditableColumn.'));
}
/**
* Renders the data cell content.
* @param integer the row number (zero-based)
* @param mixed the data associated with the row
*/
protected function renderDataCellContent($row,$data)
{
echo $this->grid->owner->widget(
'application.extensions.jeditable.DsJEditableWidget',
array(
'jeditable_type' => 'text',
'model'=>$data,
'attribute'=>$this->value,
'id'=>$data->tableSchema->name[$this->name],
'width'=>'200',
)
);
}
}
and here my gridview
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$applicationsDP,
'id'=>'gridViewApplication',
'columns'=>array(
array(
'class'=>'application.extensions.CJeditableColumn',
'name'=>'utilisateur',
'value'=>'utilisateur',
),
'id',
'utilisateur',
),
//'cssFile' => Yii::app()->request->baseUrl . '/css/gridView.css',
'htmlOptions' => array('style'=>'overflow:auto;' ),
'enablePagination'=>false, // j'arrive pas a faire marcher la pagination inside le tabview
'summaryText'=>'{count} z-info(s)',
'emptyText'=>'No z-info.',
));
When I call the gridview, I get the error : DsJEditableWidget must specify "model" and "attribute" or "name" property values.
And if I try with
protected function renderDataCellContent($row,$data)
{
echo $this->grid->owner->widget(
'application.extensions.jeditable.DsJEditableWidget',
array(
'jeditable_type' => 'text',
'model'=>$data,
'attribute'=>$this->value,
'name'=>$this->value,
'id'=>$data->tableSchema->name[$this->name],
'width'=>'200',
)
);
I get the error : Object of class DsJEditableWidget could not be converted to string
Any ideas ?
Thanks