Hide Button

Just wondering. Can we hide button in yii? For example if I have CGridView with list of names and ‘add’ button. If I click the button, the row’s id will be added to a drop down list and the button will disappear. But if the CGridView has more than one page, whenever I go to the next page and come back again, the ‘add’ button reappear again which means I can have numerous of the same id in the drop down list and I don’t want it. I want it to collect data only once.

Here is the javascript code to send the value into the drop down list.




function addNewListItem(idp){

            var htmlSelect=document.getElementById('TblDtlundangan_vidpersonil');

            

            if(htmlSelect.options.length==0){

                var jumlah=0;

            }

            jumlah++;

            var selectBoxOption = document.createElement("option");

            selectBoxOption.value = idp;

            selectBoxOption.text = idp;

            htmlSelect.add(selectBoxOption, null);

            return jumlah;

        }



And this one is the button’s code




............

array(

                        'header' => '+',

                        'type' => 'raw',

                        'value' => 'CHtml::button("+",

                                    array(

                                    "name" => "send_person".$data->vid_personil_ahm,

                                    "id" => "send_person".$data->vid_personil_ahm,

                                     "visible" =>"vis($data->vid_personil_ahm,send_person.$data->vid_personil_ahm)",

                                        "onClick" => "x=addNewListItem($data->vid_personil_ahm);

                                        $(\"#send_person$data->vid_personil_ahm\").hide();

                                        $(\"#del_person$data->vid_personil_ahm\").show()

                                        "))',

                    ),



When the page is changed a new CGridView page is retrieved from the server and whatever is rendered is what you get… so you would need to render proper buttons to solve this.