I want to show tooltip in cgridview value as on hover on column it have to show whole contant stored in variable. I want to show contant in variable $data["comment"] as a tooltip ( title ), and currently it shows whole string as - $data["comment"].
array(
'name'=>'Comment',
'header'=>'Comment',
'value'=>'(strlen($data["comment"])>35)?substr($data["comment"], 0, 35)."..":$data["comment"];',
'htmlOptions'=>array('title'=>'$data["comment"]'), // this what i have do
),
Try this:
array(
'name'=>'Comment',
'header'=>'Comment',
'type'=>'raw',
'value'=>'( strlen($data["comment"]) > 35
? CHtml::tag("span", array("title"=>$data["comment"]), CHtml::encode(substr($data["comment"], 0, 35)) . "..")
: CHtml::encode($data["comment"])
);',
),
You may need to build a custom CGridColumn class for your column and then build an expression-capable title.
I'd look at the columns that are available in the extensions area on the Yii website for ideas: http://www.yiiframework.com/extensions/?tag=column
Both of these columns do similar things (I've used and overriden both of them), so you should be able to take their ideas and make your own column class simply: http://www.yiiframework.com/extension/jtogglecolumn/ http://www.yiiframework.com/extension/gridcolumns/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With