Yii Framework Forum: How To Create Dependent Ejuicombobox - Yii Framework Forum

Jump to content

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

How To Create Dependent Ejuicombobox Rate Topic: -----

#1 User is offline   rhigel 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 18-April 13

Posted 21 May 2014 - 01:35 AM

i can create a dependent dropdownlist, but with similiar ajax script i can not create a dependent EJuiComboBox. can somebody tell me what went wrong in my code? script below is my progress so far.

by the way, the "'url'=>CController::createUrl('tx/serviceWork/GetVehicleByCustomer')" is working fine, becouse i already test with dropdownlist.

controller : serviceWork

<?php

        public function actionGetVehicleByCustomer() {
            $data = Vehicle::model()->findAll('customer_id=:customer_id', 
                                	array(':customer_id' => (int) $_POST['customer_id']));

            $data = CHtml::listData($data, 'vehicle_id', 'police_number');
            foreach ($data as $value => $name) {
                echo CHtml::tag('option', array('value' => $value), CHtml::encode($name), true);
            }
        }    
?>   



view : _form.php

        <?php
            echo '<label class="control-label" for="customer_id">Customer</label> </br>';
            $this->widget('ext.combobox.EJuiComboBox', array(
                'model' => $model,
                'attribute' => 'customer_id',
                'data' => CHtml::listData(Customer::model()->findAll(), 'customer_id', 'customer_name'),
                'options' => array(

                    'onSelect' => CHtml::ajax(array(
                            'type'=>'POST',
                            'url'=>CController::createUrl('tx/serviceWork/GetVehicleByCustomer'),
                            'update'=>'#ServiceWork_vehicle_id', 
                            'data'=>array('customer_id'=>'js:this.value'), 
                        )),                    
                    
                    'allowText' => true,
                ),
                'htmlOptions' => array('style'=> 'float:left;width:90%;'),
            ));
        ?>


before i select customer, this EJuiComboBox below still contain its own data. but after i select customer, this EJuiComboBox data is all gone. so, i think the ajax is working, but i miss something probably.

        <?php
            echo '<label class="control-label" for="vehicle_id">Vehicle</label> </br>';
            $this->widget('ext.combobox.EJuiComboBox', array(
                'model' => $model,
                'attribute' => 'vehicle_id',
                'data' => CHtml::listData(Vehicle::model()->findAll(), 'vehicle_id', 'police_number'),
                'options' => array(
                    'allowText' => true,
                ),
                'htmlOptions' => array('style'=> 'float:left;width:90px;'),
            ));
        ?>



thank you. :)
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