Hi there,
How can I get actual content of a cell to use it to customise CLinkColumn or to make CButtonColumn work with non-model data providers in CGridView?
I have a controller and view using CGridView along with CActiveDataProvider and it works perfectly. I then copied view code do another view (and controller) and the only thing, I changed was to switch data provider from CActiveDataProvider (Active Record) to CSqlDataProvider (pure SQL query).
The first thing I noticed was "Trying to get property of non-object" in the line of code declaring CButtonColumn:
array
(
'class'=>'CButtonColumn',
'template'=>'{view}'
)
If I’m not mistaken, this is because I’m using CSqlDataProvider and CButtonColumn seems to be looking for some model property, right? Then the question is how to use CButtonColumn, if not using model-related data provider?
Another problem is with CLinkColumn, which I’m trying to customize with its own contents, for example like that:
array
(
'class'=>'CLinkColumn',
'labelExpression'=>'$data->UDAT',
'url'=>$url,
'htmlOptions'=>array('title'=>$title),
),
But this also dies with exactly the same error (“Trying to get property of non-object” in yii\base\CComponent.php(616) with eval()'d code(1)), which is also OK if I’m not mistaken, as CLinkColumn.labelExpression says that $data can be only used when data provider is a model.
So, second question is, that if this piece of code works:
'UDAT:text:Date',
for declaring simple CDataColumn, then how be able to use CLinkColumn in the same context, that is to have cell contents put into label or labelExpression and value of another cell (another column of current data row) - i.e. ID - to be put into url or urlExpression?