row attribute CDetailView

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 &#036;itemTemplate=&quot;&lt;tr class=&#092;&quot;{class}&#092;&quot;&gt;&lt;th&gt;{label}&lt;/th&gt;&lt;td [b]{htmloptions}[/b]&gt;{value}&lt;/td&gt;&lt;/tr&gt;&#092;n&quot;;
  1. in the run function

     		else
    
    
     			&#036;tr['{label}']=ucwords(trim(strtolower(str_replace(array('-','_','.'),' ',preg_replace('/(?&lt;&#33;[A-Z])[A-Z]/', ' &#092;0', &#036;attribute['name'])))));
    
    
     	}
    

[b]//++ Added in CISDetailView

		if (isset (&#036;attribute['htmloptions'])) {


			&#036;tr['{htmloptions}'] = &#036;attribute['htmloptions'];


		}

//–

[/b] if(!isset($attribute[‘type’]))

			&#036;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'=&gt;&#036;model,


'attributes'=&gt;array(


	'C_Project',


	'T_Description',


            ...


	array(


		'name'=&gt;'N_Organisation_FK',


		'type'=&gt;'raw',


		'value'=&gt;CHtml::link(&#036;model-&gt;nOrganisationFK-&gt;Displaytext, array(&quot;TdOrganisation/view&quot;, &quot;id&quot;=&gt;&#036;model-&gt;N_Organisation_FK)),


	),


	'T_HealthReference',


	array(


		'name'=&gt;'N_Health_FK',


		'type'=&gt;'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)