Yii, show tooltip in cgridview (table) value

I want to show a tooltip in the value of cgridview, as when hovering over a column, it should display the whole constant stored in the variable. I want to show contant in the variable $ data ["comment"] as a hint (name), and currently it shows the whole line 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 ), 
+6
source share
2 answers

Try the following:

 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"]) );', ), 
+8
source

You may need to create your own CGridColumn class for your column, and then create an expression-enabled header.

I would look at the columns that are available in the extension area on the Yii website: http://www.yiiframework.com/extensions/?tag=column

Both of these columns do similar things (I used them and redefined them), so you should be able to take your ideas and just create your own column class: http://www.yiiframework.com/extension/jtogglecolumn/ http: // www .yiiframework.com / extension / gridcolumns /

+1
source

Source: https://habr.com/ru/post/918235/


All Articles