Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use text in CGridview dropdownlist instead of values
    primarykey
    data
    text
    <p>I'm new to Yii. I have a gridview with search boxes. One of these search boxes has to be replaced by dropdown list. Based on the dropdownlist value the value in the gridview cells should be replaced.</p> <p>Suppose, I use <code>(0-&gt; No Activity, 1-&gt;Pending, 2-&gt;Approved, 3-&gt; Rejected)</code>. I need to replace the values 0 with No Activity, 1 with Pending, 2 with Approved, 3 with Rejected respectively both in Gridview cell and dropdownlist.</p> <p>What should I mention in the value of the array</p> <pre><code>array( 'name' =&gt; 'Test', 'value' =&gt; 'filter' =&gt; array('0' =&gt; 'No Activity', '1' =&gt; 'Pending','2' =&gt; 'Approved', '3' =&gt; 'Rejected',''=&gt;'All'), 'htmlOptions' =&gt; array('style' =&gt; 'width: 500px;'), ), </code></pre> <p>I'm using <code>PHP 5.2</code> and <code>Yii version 1.13</code> </p> <p>I edited the below code , and this works fine for me </p> <p><strong><code>EDIT :</code></strong> </p> <pre><code>function getTestType($test) { $testTypesList = array('0'=&gt; 'No Activity', '1'=&gt;'Pending', '2'=&gt;'Approved', '3'=&gt; 'Rejected',''=&gt;'All'); if(is_null($test)){ return 'All'; }else{ return $test=$testTypesList[$test]; } } </code></pre> <p>and in view</p> <pre><code>array( 'name' =&gt; 'Test', 'value' =&gt;'getTestType($data-&gt;textfield)' 'filter' =&gt; array('0' =&gt; 'No Activity', '1' =&gt; 'Pending','2' =&gt; 'Approved', '3' =&gt; 'Rejected',''=&gt;'All'), 'htmlOptions' =&gt; array('style' =&gt; 'width: 500px;'), ), </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload