Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Dropdown List A Cascata

$
0
0
Ho la necessita di poter popolare una seconda dropdown list in base alla selezione di una prima dropdown centrodicosto->servizi. Ho provato ad utilizzare l'estenzione ECascadeDropDown ma non riesco ad ottenere nessun dato nella seconda dropdown.
Il codice che ho inserito seguendo il seguente link cascadedropdown nel form ho :

$ccItems = CHtml::listData(Centricosto::model()->findAll(), 'idCentroCosto', 'dsCentroCosto');
echo CHtml::activeDropDownList($model, 'idCCPartenza', $ccItems, array('idCCPartenza'=>'idCentroCosto','prompt'=>'-'));

$s1Items = CHtml::listData(Servizi::model()->findAll('idCentroCosto=:idCentroCosto',array(':idCentroCosto'=>$model->idCCPartenza)),'idServizio','dsServizio');
echo CHtml::activeDropDownList($model, 'idServizioPartenza', $s1Items, array('idServizio'=>'idServizioPartenza','prompt'=>'-'));

ECascadeDropDown::master('idCCPartenza')->setDependent('idServizioPartenza',array('dependentLoadingLabel'=>'Loading cities ...'),'Site/servizidata');
?>

Mentre nel siteController.php ho riportato il seguente codice:
public function actionServizidata()
{
//check if isAjaxRequest and the needed GET params are set
ECascadeDropDown::checkValidRequest();

//load the cities for the current province id (=ECascadeDropDown::submittedKeyValue())
$data = Servizi::model()->findAll('idCentroCosto=:idCentroCosto', array(':idCentroCosto'=>ECascadeDropDown::submittedKeyValue()));

//Convert the data by using
//CHtml::listData, prepare the JSON-Response and Yii::app()->end
ECascadeDropDown::renderListData($data,'idServizio', 'dsServizio');
}

Non riesco a capire cosa non vada ??? Grazie a tutti

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>