Saving Multiple Column Values Using A Single Button In Cgridview

I really had a hard time figuring it out so I am kindly asking you to help me with this.

I am trying to save multiple column values in CGridView using a button. So I have something like this:

5579

Screenshot from 2014-05-15 16:04:55.png

I followed this tutorial Click but I did not understand it well so I just copied what he said in the Model:




public function getDecidedMode(){


		 $modes = array(

        	1 => 'Value1',

        	2 => 'Value2',

        	3 => 'Value3',

		4 => 'Value4',

        	5 => 'Value5',

   		 );

    		

		return CHtml::dropDownlist('decided_mode',$this->decided_mode,$modes, array(

       		 'class'     => 'decided_mode',

       		 'data-id'   => $this->id,

   		 ));

	}



In my view:




...

array(

   		 'name'  => 'decided_mode',

   		 'type'  => 'raw',

   		 'value' => '$data->DecidedMode',

			

),

...



Now, I want to create a button at the bottom that will handle ActionSave in order to save all values in each column selected. I need some code to try for it to finally finally work.

Thank you guys.Hope you can give me some code here.

Do you want save a record in model through CGridview?

check these

http://www.yiiframework.com/wiki/682/insert-a-model-record-using-cgridview/

http://www.yiiframework.com/wiki/597/update-a-part-of-content-using-ajax-when-select-a-gridview-row/

What exactly you want to do?

Hello KonApaz. Can I changed the value of model attribute after I select from dropdown in CGridview? Meaning, if I choose value from dropdownlist then my model attribute will now contain the new chosen value and save it to my database. Hope you can help me. Thank you.

Yes you can!

Making a button that send the row data to a controller/action through ajax, you can update the specific model

check this for more details

http://www.yiiframework.com/wiki/658/update-cgridview-row-separately-using-ajax-request/