Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii , show tooltip in cgridview( table ) value

Tags:

php

yii

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
                    ),
like image 211
Kiran Avatar asked Jun 16 '12 11:06

Kiran


2 Answers

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"])
    );',
),
like image 95
Sarke Avatar answered Oct 12 '22 11:10

Sarke


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/

like image 42
acorncom Avatar answered Oct 12 '22 11:10

acorncom