I use yii and Yii Booster.
I want to truncate text displayed in a TbEditableColumn. I have extended CFormatter as described here: .
In order to truncate text I set in my column definition attribute 'type' to array('type'=>'shortText', length=>20)
//gridview
'columns'=>array(
array(
'type' => array(
'type' => 'shortText',
'length' => 10
),
),
)
It works fine in columns that are NOT editable. It doesn't work when I set:
'class' => 'bootstrap.widgets.TbEditableColumn'
Any idea how to make it work with TbEdiableColumn?
Now that's been a brain tickler. Although
TbEditableColumnultimately extendsCDataColumn, it does not respect the grid view's formatter at all if it is able to apply theTbEditableFieldwidget to the data cell.TbEditableFieldhas atextproperty controlling the displayed text in the data cell (that is, before you clicked it). Unfortunately, it seems to be static. It never gets evaluated in any form, so you can't pass an expression or an anonymous function to it.Bottom line: Can't be done unless you're teaching
TbEditableFieldhow to pull in formatters by extending it.TbEditableColumnwould have to be extended as well so it'll pass the formatter instance.