Yii Framework Forum: Cant Make Jquery-Cascade To Generate Second Dropdownlist - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Cant Make Jquery-Cascade To Generate Second Dropdownlist Rate Topic: -----

#1 User is offline   Enrique Salazar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 29-January 13

Posted 29 January 2013 - 11:38 AM

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.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users