rasha1489
(Rasha1489)
June 13, 2013, 10:16pm
1
hi, i tried to apply the n level drop down list based on this link.
echo CHtml::dropDownList('CycleID','', CHtml::listData(Usersectionsecurity::model()->findAll(), 'Group_Code', 'E_Group_Desc'),
array(
'prompt'=>'Select Cycle',
'ajax' => array(
'type'=>'POST', //request type
'url'=>CController::createUrl('Usersectionsecurity/getClassByCycle'), //url to call.
'update'=>'#stclass',
)
));
echo CHtml::dropDownList('stclass', '', array(),
array(
'prompt'=>'Select Class',
'ajax' => array(
'type'=>'POST', //request type
'url'=>CController::createUrl('Assignment/getStudentByClass'), //url to call.
'update'=>'#'.CHtml::activeId($model,'studentID'),
)));
echo $form->dropDownList($model,'studentID',array(), array('empty'=>'Select Student'));
the code is working fine, when i select the cycle, automatically the appropriate value of the classes including in this cycle are displayed. for example if i select the cycle 1 from cycle list, class grade 1, 2,… appears and grade 1 at the top.
to get the student of the grade 1, i have to select another value from the list and then re-select grade 1 to make the student name appears in the list.
why this? can anyone give me a solution. is there is select instead of update or something else?
thank you…
hi, i tried to apply the n level drop down list based on this link.
echo CHtml::dropDownList('CycleID','', CHtml::listData(Usersectionsecurity::model()->findAll(), 'Group_Code', 'E_Group_Desc'),
array(
'prompt'=>'Select Cycle',
'ajax' => array(
'type'=>'POST', //request type
'url'=>CController::createUrl('Usersectionsecurity/getClassByCycle'), //url to call.
'update'=>'#stclass',
)
));
echo CHtml::dropDownList('stclass', '', array(),
array(
'prompt'=>'Select Class',
'ajax' => array(
'type'=>'POST', //request type
'url'=>CController::createUrl('Assignment/getStudentByClass'), //url to call.
'update'=>'#'.CHtml::activeId($model,'studentID'),
)));
echo $form->dropDownList($model,'studentID',array(), array('empty'=>'Select Student'));
the code is working fine, when i select the cycle, automatically the appropriate value of the classes including in this cycle are displayed. for example if i select the cycle 1 from cycle list, class grade 1, 2,… appears and grade 1 at the top.
to get the student of the grade 1, i have to select another value from the list and then re-select grade 1 to make the student name appears in the list.
why this? can anyone give me a solution. is there is select instead of update or something else?
thank you…
make the first value as “‘prompt’=>‘Select Class’,”
this should be in the controller action as first value
example
public function actionLoadcities()
{
$data=RegionCity::model()->findAll('region_id=:region_id',
array(':region_id'=>(int) $_POST['region_id']));
$data=CHtml::listData($data,'id','city_name');
echo "<option value=''>Select City</option>";
foreach($data as $value=>$city_name)
echo CHtml::tag('option', array('value'=>$value),CHtml::encode($city_name),true);
}
note this line
echo "<option value=''>Select City</option>";