mark2bra
(Mark2bra)
April 8, 2014, 4:45pm
1
I made a ClinkColumn :
array(
'class'=>'CLinkColumn',
'header'=>'link to law source',
'labelExpression'=>'link',
'urlExpression'=>'$data->relatedlinks',
'htmlOptions'=>array('style' => 'text-align: center;','width'=>'40px'),
),
which is working well , but not quite user friendly:
The blue "link" is being shown in every cell , even if it is NULL
When I click on the link , the row is being selected (marked in green)
I couldn’t find the answers for these two , so does anyone have suggestions?
Keith
(Kburton)
April 8, 2014, 8:01pm
2
I’ve not used CLinkColumn, but here’s an easy way to do it with a CDataColumn:
array(
'type'=>'raw',
'header'=>'link to law source',
'htmlOptions'=>array('style' => 'text-align: center;','width'=>'40px'),
'value'=>function($data){
if ($data->relatedlinks === null)
return '';
return CHtml::link('link', $data->relatedlinks, array('class'=>'law-link'));
},
),
You could add something like this to prevent the highlighting of the row (untested, so it may need tweaking):
<script type="text/javascript">
$("body").on("click", "a.law-link", function(e){
e.stopPropagation();
return true;
});
</script>
mark2bra
(Mark2bra)
April 9, 2014, 8:00am
3
Bombora!
Thanks Keith!
Both codes are working well!
Cheers,
Mark.
mark2bra
(Mark2bra)
May 8, 2014, 4:32pm
4
Ok , a small edit:
I had to modify the line where if there is no link , the word itself won’t be showed, however , I still get it sometimes , even that in the DB that field is NULL.
Any ideas why?
'value'=>function($data){
if ($data->relatedlinks == null or $data->relatedlinks == ' ')
return '';
return CHtml::link('link', $data->relatedlinks, array('class'=>'law-link'));
},