Hi all.
I have really surfed google, forums and the documentation trying to avoid asking here, but I am getting hopeless.
I have installes the JQuery-Cascade Extension.
In the View I have
<?php
$divipola = $this->createWidget('ext.jquery-cascade.jQueryCascade');
// dropDownList($id, $selected, $data, $htmlOptions = array(), $source, $cascaded)
echo $divipola->dropDownList('depto_dane',
'',
CHtml::listData(Codigodane::model()->findAll(), 'depto_dane', 'depto_dane'),
'',
CController::createUrl('codigodane/list'),
'muni_dane'.
''
);
echo Yii::trace(CVarDumper::dumpAsString($divipola), 'vardump');
?>
In the Controller:
public function actionList() {
echo Yii::trace(CVarDumper::dumpAsString('Entrando a actionList'), 'vardump');
if (Yii::app()->request->isAjaxRequest) {
$queryvar = "";
$queryvar.="depto_dane='";
$queryvar.=$_GET['selected'];
$queryvar.="'";
$registro = Codigodane::model()->findAll($queryvar);
$munis = array();
echo Yii::trace(CVarDumper::dumpAsString($registro), 'vardump');
foreach ($registro as $muni) {
echo Yii::trace(CVarDumper::dumpAsString($muni), 'vardump');
$munis[] = array('label' => $muni->muni_dane, 'value' => $muni->codigodane);
}
echo json_encode($munis);
Yii::app()->end();
} else {
throw new CHttpException(400, 'Invalid request.');
}
}
The code seems to be working fine, the first dropdownlist is flawless rendered, and when I select an option it successfully retrives an array from the model exactly as I need it (which I can see in firebug):
[{"label":"FLORENCIA","value":"18001"},{"label":"ALBANIA","value":"18029"},{"label":"BELEN DE LOS ANDAQUIES","value":"18094"},{"label":"CARTAGENA DEL CHAIRA","value":"18150"},{"label":"CURILLO","value":"18205"},{"label":"EL DONCELLO","value":"18247"},{"label":"EL PAUJIL","value":"18256"},{"label":"MONTA\u00d1ITA","value":"18410"},{"label":"MILAN","value":"18460"},{"label":"MORELIA","value":"18479"},{"label":"PUERTO RICO","value":"18592"},{"label":"SAN JOSE DEL FRAGUA","value":"18610"},{"label":"SAN VICENTE DEL CAGUAN","value":"18753"},{"label":"SOLANO","value":"18756"},{"label":"SOLITA","value":"18785"},{"label":"VALPARAISO","value":"18860"}]
What I dont know is how to use this array to create another dropdownlist or if (as I think) the Extension should create the another dropdownlist with ID ‘muni_dane’.
I am doing something wrong? or maybe I missed something from the documentation?
Thanks.
Enrique.