CGridView filter selectbox multiple

Hello,

This is my first post on this forum, I am a beginer in Yii.

Here is my problem, I added in a CGridView widget a column filter (dropDown select multiple)




array(

	'name' => 'data_end',

	'header' => 'Tip contract',

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

	'filter' => CHtml::activeDropDownList($model, 'data_end', array('activ' => 'activ', 'expirat' => 'expirat', 'perioada_determinata' => 'perioada determinata'), array('multiple' => 'true', 'size' => 3))

)



How may I select more then one value and after, submit data ?

Now when I click the selectbox my CGridView submit data (default behaviour).

Found a solution, thanx anyway.

care to share?

Read WARNING too please.

Basic ideea is to add a checbox in the filter (or something else) and then overwrite $.fn.yiiGridView




// temporary fix for the bug of supporting live change in IE

$(inputSelector).live($.browser.msie ? 'click keyup' : 'change', function(){

  if($('#submit_filter').is(':checked')){

//  var data = $.param($(inputSelector))+'&'+settings.ajaxVar+'='+id;

    var data = $('.filters :input').serialize();

    $.fn.yiiGridView.update(id, {data: data});

  }

});



where #submit_filter is checkbox id. Now you can select any filters you like and when check the #filter_submit,

filter will apply.

!!! WARNING !!!

After I did this change, my link for sort looks like:




http://localhost/user/admin/User%5Blast_name%5D//User%5Bdata_angajare_end%5D%5B0%5D/perioada_determinata/User%5Bdata_angajare_end%5D%5B1%5D/perioada_nedeterminata/User%5Bdepartment%5D//submit_filter/1/ajax/transactions-grid/User_sort/data_angajare_start



This field is select multiple in my case:




User%5Bdata_angajare_end%5D%5B0%5D/perioada_determinata/User%5Bdata_angajare_end%5D%5B1%5D/perioada_nedeterminata



If you want to see it in controller:




User[data_angajare_end] = array(0 => option_1, 1 => option_2) 



and not




User[data_angajare_end] = option_1



I had to change CUrlManager-> parsePathInfo();




public function parsePathInfo($pathInfo)

	{

		if($pathInfo==='')

			return;

		$segs=explode('/',$pathInfo.'/');

		$n=count($segs);

		for($i=0;$i<$n-1;$i+=2)

		{

			$key=$segs[$i];

			if($key==='') continue;

			$value=$segs[$i+1];

			if(($pos=strpos($key,'['))!==false && ($pos2=strpos($key,']',$pos+1))!==false)

			{

				$name=substr($key,0,$pos);

				if($pos2===$pos+1)

					$_REQUEST[$name][]=$_GET[$name][]=$value;

				else

				{

					$key=substr($key,$pos+1,$pos2-$pos-1);

					if(is_array($_REQUEST[$name]) && array_key_exists($key, $_REQUEST[$name])){

						if(!is_array($_REQUEST[$name][$key])){

							$mOldValue = $_REQUEST[$name][$key];

							unset($_REQUEST[$name][$key]);

							$_REQUEST[$name][$key]=$_GET[$name][$key]=array($mOldValue);

						}

						$_REQUEST[$name][$key][]=$_GET[$name][$key][]=$value;

					} else {

						$_REQUEST[$name][$key]=$_GET[$name][$key]=$value;

					}

//					echo '<pre>'.print_r($_REQUEST, true).'</pre>';

				}

			}

			else

				$_REQUEST[$key]=$_GET[$key]=$value;

		}

	}



!!! end warning !!!

If anyone found an elegant solution please share, thank you !

big thanks for your ParsePathInfo() function!!!