Hi guys,
Is there anyway to arrange CDetailView row style all to left hand side. The default CDetailView show the view in right hand side.
For example, Cdetalview
Thanks,
Hi guys,
Is there anyway to arrange CDetailView row style all to left hand side. The default CDetailView show the view in right hand side.
For example, Cdetalview
Thanks,
I don’t understand what you mean with left/right hand… is it the columns or the text-alignment ?
For the first… you need to change the layout file… for the second the CSS rules…
sorry.
i mean the text-alignment for firstname, lastname,…,registered move to left. for example like array(‘style’ => ‘text-align:left;’). How to show in Cdetailview. Pls gv me some idea, thx.
Check the HTML source generated… and just add a CSS rule for this…
Attributes names are rendered as TH…
Hi mdomba, where i need add CSS rule for this
Attributes names are rendered as TH...
Based on CDetailView:: playground, how to make the firstname, lastname, birth, till registered text-alignment some sort like array(‘style’ => ‘text-align:left;’).
Thanks, Anyone got did it before. Please helps.
Got anyone solve this before? Please give me some suggestion. Thank,=)
What I did is copy the CDetailView.php as CISDetailView in the components directory.
I made three little changes in CISDetailView.php (a copy of CDetailView):
//original class CDetailView extends CWidget
class CISDetailView extends CWidget
// original CDetailView public $itemTemplate="<tr class=\"{class}\"><th>{label}</th><td>{value}</td></tr>\n";
public $itemTemplate="<tr class=\"{class}\"><th>{label}</th><td [b]{htmloptions}[/b]>{value}</td></tr>\n";
in the run function
else
$tr['{label}']=ucwords(trim(strtolower(str_replace(array('-','_','.'),' ',preg_replace('/(?<![A-Z])[A-Z]/', ' \0', $attribute['name'])))));
}
[b]//++ Added in CISDetailView
if (isset ($attribute['htmloptions'])) {
$tr['{htmloptions}'] = $attribute['htmloptions'];
}
//–
[/b] if(!isset($attribute[‘type’]))
$attribute['type']='text';
With these additions I can change the text- and background color based on the HEX-values of parameters that are related to my model. For example: the health of a project is set by a parameter- table, each item in that table has its own colors that can be changed by a system user.
So my an extract of the view:
<?php $this->widget(‘CISDetailView’, array(
'data'=>$model,
'attributes'=>array(
'C_Project',
'T_Description',
...
array(
'name'=>'N_Organisation_FK',
'type'=>'raw',
'value'=>CHtml::link($model->nOrganisationFK->Displaytext, array("TdOrganisation/view", "id"=>$model->N_Organisation_FK)),
),
'T_HealthReference',
array(
'name'=>'N_Health_FK',
'type'=>'raw',
[b] ‘htmloptions’=>‘style=color:’.$model->nHealthFK->C_TextHEXColorcode.’;background-color:’.$model->nHealthFK->C_HEXColorcode.’;’,
[/b] ‘value’=>$model->nHealthFK->Displaytext,
),
'D_HealthChanged',
...
I hope this is usefull and understandable (I’am Dutch speaking)